4 Replies Latest reply on Dec 12, 2014 6:23 PM by James Perkins

    jboss configuration

    André Faber Newbie

      Hello,

       

      I'm trying to add the program name in the logging message because I use an common class and if this class is logging I

      only get a message like:

      2014-11-26 11:16:37,345 INFO [lu.etat.pch.common.alfresco.AlfrescoResource] (default task-54) Creating new Alfresco session

      without knowing which application throw this message.

       

      I saw that I can customize the log message in my standalone.xml file by changing the

      <pattern-formatter pattern="%K{level}%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>

      pattern.

       

      Is there a possibly to add the programm name to that setting? Or does anyone has another idea how I can (easily) do this?

       

      Thanks in advance

        • 1. Re: jboss configuration
          Peter Johnson Master

          There is no way for the logger to know the name of the deployed application responsible for this log entry. The best you can do (and what has worked well for me) is to look at the thread name and follow it through the log. Provided that the deployed application does some of its own logging, you should be able to determine which common class log entries go with which application. In my case, I make a log entry when a request comes in and another when I reply, making it easy to track individual requests. Just be aware that threads are pooled and reused, so the same thread will not always handle requests for the same application; but a single thread will handle an entire request.

          1 of 1 people found this helpful
          • 2. Re: jboss configuration
            André Faber Newbie

            I solved my issue by using one log file per deployement by using this jboss-logging.properties file:

             

            # Root logger level
            logger.level=INFO
            # Root logger handlers
            logger.useParentHandlers=true
            logger.handlers=APPFILE,SERVERFILE,CONSOLE

            # Console handler configuration
            handler.CONSOLE=org.jboss.logmanager.handlers.ConsoleHandler
            handler.CONSOLE.properties=autoFlush
            handler.CONSOLE.level=INFO
            handler.CONSOLE.autoFlush=true
            handler.CONSOLE.formatter=PATTERN

            # File handler configuration
            handler.APPFILE=org.jboss.logmanager.handlers.PeriodicRotatingFileHandler
            handler.APPFILE.properties=autoFlush,append,fileName,suffix,enabled
            handler.APPFILE.constructorProperties=fileName,append
            handler.APPFILE.suffix=.yyyy-MM-dd
            handler.APPFILE.append=true
            handler.APPFILE.autoFlush=true
            handler.APPFILE.fileName=${jboss.server.log.dir}/${project.artifactId}/${project.artifactId}-wildfly-${classifier}.log
            handler.APPFILE.formatter=PATTERN
            handler.APPFILE.enabled=true

            # File handler configuration
            handler.SERVERFILE=org.jboss.logmanager.handlers.PeriodicRotatingFileHandler
            handler.SERVERFILE.properties=autoFlush,append,fileName,suffix,enabled
            handler.SERVERFILE.constructorProperties=fileName,append
            handler.SERVERFILE.suffix=.yyyy-MM-dd
            handler.SERVERFILE.append=true
            handler.SERVERFILE.autoFlush=true
            handler.SERVERFILE.fileName=${jboss.server.log.dir}/server.log
            handler.SERVERFILE.formatter=PATTERN
            handler.SERVERFILE.enabled=true

            # Formatter pattern configuration
            formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter
            formatter.PATTERN.properties=pattern
            formatter.PATTERN.pattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n


            It writes my logging to the default "server.log" file, the console and in addition to a logging file [programmname].log.

            But unfortunately a new problem appeared: Every day the log should be renamed as [logfile].log.%yyyy-MM-dd and a new log should be started.

            This is done for my [application].log log file but the server.log is not renamed.


            Is my configuration file fauly?

            • 3. Re: jboss configuration
              ksreen Newbie

              You can try the method suggested in this blog  http://blog.jyore.com/?p=234

              • 4. Re: jboss configuration
                James Perkins Master

                You could use an MDC entry. You'd just need to add something like %X{appName} to the pattern and ensure the appName is set in MDC.

                 

                --
                James R. Perkins