Pimp my Log
Last updated
Last updated
Logs are very important. And we know about the frustration when not being able to access it easily. And that's why every dockware images comes with an installed Pimp my Log log viewer.
Open the log viewer in your web browser with /logs of the domain you use:
Switch between different prepared logs, such as Apache error logs, access logs as well as Shopware logs for either production or development.
Dockware has been prepared to show the Shopware and Apache default logs. But what if you want to add custom log files from your shop or the plugin you are developing?
That's easy too!
Let's imagine you create a new plugin with a custom log file. That one has probably the name of your plugin, as well as the environment and probably datetime.
You can add your custom log file, by simply adding a new JSON configuration to Pimp my Log. Do this, by mounting your own file into the folder /var/www/pimpmylog/config.user.d as shown here:
The content of the file can just look like this. It has the name that will be used in the web application, a path to your log file using a pattern expression, and information about the way how your log line is structured.
This is a sample that parses the following type of log entry.
Datetime | Severity | Error Message | File | Line |
You can find more examples on the Pimp my Log website.
Here is a video that shows you how it would look like.
Logging is far more interesting when it comes to decentralized systems, such as with the ones you'll be building when creating Shopware Apps.
If you are not logging using Filebeats and an ELK system (Elastic - Logstash - Kibana), then you are probably in the need of seing your log files from your backend service.
This can easily be done with the built-in Pimp my Log application of your Shopware container. Please keep in mind, this is only an easy approach to reuse that application. We still recommend a dedicated container and setup for perfect logging across different containers.
Sending your logs from your backend service to your Shopware container is easy. We can just use bind-mounting for that log folder. So we get the log folder onto our host machine (step 1), and then pass that on to the Shopware container by bind-mounting it to any folder inside that container (step 2). Please use an empty directory somewhere in the Shopware container.
If you do not want to use the local host with bind-mounting, you can also use simple volume mounting or anything else. Just make sure that folder is connected to both containers.
Now you have successfully connected the logs from the backend service with the folder inside your Shopware container.
The next thing is, to correctly configured our additional configuration JSON for Pimp my Log, which is already mounted into the Shopware container too (step 3). This snippet only focuses on the display name and path. Please see the example above for a full code snippet.
That's it!
If you now start your containers, you should already see a filter "Backend Service Logs" in Pimp my Log, and logs should be visible, if existing.