Enonic App Logs to specific file

Hello there,

Guys I’m wondering if does it possible to write logs to a specific file.

Currently, all my logs of my “part1” and “service1” are being stored in home/logs/Server.log. Does it possible that logs of “part1” start to being saved in home/logs/part1.log and the same as “service1”, home/logs/service1.log

This is to organize our server logs split them fin functionality in different files. How can I do that?




i’ve too much logs in server.log file and i wish separate that ¿it’s posible? :frowning:

You should use log analyzing tools to separate/query your logs. Check out Elastic for instance.

Well not by part/service, but you can divide by application.
You will need to modify the configuration file “logback.xml”

An example to log all INFO/WARN/ERROR logs from an application “com.enonic.app.myapp” to a file “myapp.log” (in addition to the logging into the console and server.log):

<appender name="MYAPP_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
  <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
    <pattern>%d{HH:mm:ss.SSS} %-5level %logger{36} - %msg%n</pattern>

<logger name="com.enonic.app.myapp">
  <level value="INFO" />
  <appender-ref ref="MYAPP_FILE"/>

If you do not want to log into server.log, but only in the console and myapp.log, replace the logger part by the one below:

<logger name="com.enonic.app.myapp" additivity="false">
  <level value="INFO" />
  <appender-ref ref="MYAPP_FILE"/>
  <appender-ref ref="STDOUT"/>