1 Reply Latest reply on Jul 26, 2017 11:45 AM by Amit Kumar

    How to create separate log file rather than server log in switchyard and wildfly 8

    hemant patha Newbie

      Hello,

       

      I am trying to create my own log file to check the log rather than server log in switchyard. i am using wildfly 8.0 server and my requirement is not to use camel at all. I did try with adding file appender in log4j.xml, but it is not even creating the log file where i specified the location. Can anyone can guide me to create my own log file.

       

      Thanks in advance

      Hemant

        • 1. Re: How to create separate log file rather than server log in switchyard and wildfly 8
          Amit Kumar Newbie

          Wildfly has a logging subsystem which can be found in standalone.xml/domain.xml.

           

          This subsystem can be modified for creating separate log files. It supports several handlers like periodic-rotating-file-handler, size-rotating-file-handler, custom-handler (in case you have your own logging implementation), etc...

           

          You can select a handler as per your requirement and a corresponding logger category has to be created.

           

          In order to modify the standalone.xml/domain.xml file directly :

           

           

          <periodic-rotating-file-handler name="MYLOG" autoflush="true">
              <formatter>
                  <pattern-formatter pattern="%d{dd-MM-yyyy HH:mm:ss,SSS}|%-5p|%m%n"/>
              </formatter>
              <file relative-to="jboss.server.log.dir" path="mylog_example.log"/>
              <suffix value=".yyyy-MM-dd"/>
              <append value="true"/>
          </periodic-rotating-file-handler>
          <logger category="com.mylog.example" use-parent-handlers="false">
              <level name="INFO"/>
              <handlers>
                  <handler name="MYLOG"/>
              </handlers>
          </logger>
          

          In case you are using CLI :

           

          /subsystem=logging/periodic-rotating-file-handler=MYLOG:add(autoflush="true", formatter="%d{dd-MM-yyyy HH:mm:ss,SSS}|%-5p|%m%n", file={"relative-to"=>"jboss.server.log.dir","path"=>"mylog_example.log"}, suffix=".yyyy-MM-dd", append=true)
          
          /subsystem=logging/logger=com.mylog.example:add(use-parent-handlers=false, handlers=[handler="MYLOG"], level=INFO)
          

           

           

          Hope this helps!!!