javajakarta-eeloggingwildfly-8

How to generate server.log in custom folder location in wildfly-8.2.0.Final


I am facing a problem regarding server.log file generation in Wildfly-8.2.0.Final AS.

Below is the size-rotating-file-handler definition used in logging subsystem <subsystem xmlns="urn:jboss:domain:logging:2.0"> of standalone-full-ha.xml.

<size-rotating-file-handler name="FILE" autoflush="false">
      <level name="DEBUG"/>
      <file relative-to="jboss.server.log.dir" path="server.log"/>
      <rotate-size value="500k"/>
      <max-backup-index value="5"/>
      <append value="true"/>
</size-rotating-file-handler>

The above works fine and it generates server.log in ${WILDFLY_HOME}/standalone/log folder. I would like to have a custom location for server.log and hence, modified the path attribute to contain the complete custom path and removed relative-to attribute as shown below.

<file path="D:/wildfly-8.2.0.Final/standalone/log/server.log"/>

But, with the above changes, server.log is getting generated in custom location but facing the below problems:

Please help me.

Edited on 10/May/2016: added the below configuration.

<subsystem xmlns="urn:jboss:domain:logging:2.0">
        <add-logging-api-dependencies value="false"/>
        <use-deployment-logging-config value="true"/>
        <console-handler name="CONSOLE">
            <level name="INFO"/>
            <formatter>
                <named-formatter name="PATTERN"/>
            </formatter>
        </console-handler>
        <size-rotating-file-handler name="FILE" autoflush="false">
            <level name="DEBUG"/>
            <file path="${custom.path}/server.log"/>
            <rotate-size value="500k"/>
            <max-backup-index value="5"/>
            <append value="false"/>
            <formatter>
                <named-formatter name="PATTERN"/>
            </formatter>
        </size-rotating-file-handler>
        <logger category="com.arjuna">
            <level name="WARN"/>
        </logger>
        <logger category="org.apache.tomcat.util.modeler">
            <level name="WARN"/>
        </logger>
        <logger category="org.jboss.as.config">
            <level name="DEBUG"/>
        </logger>
        <logger category="sun.rmi">
            <level name="WARN"/>
        </logger>
        <logger category="jacorb">
            <level name="WARN"/>
        </logger>
        <logger category="jacorb.config">
            <level name="ERROR"/>
        </logger>
        <root-logger>
            <level name="INFO"/>
            <handlers>
                <handler name="CONSOLE"/>
                <handler name="FILE"/>
            </handlers>
        </root-logger>
        <formatter name="PATTERN">
            <pattern-formatter pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
        </formatter>
        <formatter name="COLOR-PATTERN">
            <pattern-formatter pattern="%K{level}%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
        </formatter>
    </subsystem>

Solution

  • Seems that you did not specified a pattern (and probably this is why the date/time are not in the log).

    <size-rotating-file-handler name="FILE" autoflush="false">
      <level name="DEBUG"/>
      <file path="D:/wildfly-8.2.0.Final/standalone/log/server.log"/>
      <rotate-size value="500k"/>
      <max-backup-index value="5"/>
      <append value="true"/>
      <formatter>
       <named-formatter name="PATTERN"/>
      </formatter>
    </size-rotating-file-handler>
    

    Pattern example with date/time:

    <formatter name="PATTERN">
      <pattern-formatter pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n"/>
    </formatter>
    

    Can you provide full log configuration? Maybe the "server is started..." is not showing because you didnt put the file handler in right category.