How in JBoss to write traces to separate file?
I would like to see traces about org.hibernate.SQL and org.hibernate.type in separate trace file.
I added next appender and categories to jboss-log4j.xml but it does not help - jboss still writes traces into server.log.
<appender name="HIBERNATE" class="org.jboss.logging.appender.DailyRollingFileAppender">
<errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
<param name="File" value="/u1/trace/sql.log"/>
<param name="Append" value="true"/>
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n"/>
</layout>
</appender>
<category name="org.hibernate.SQL">
<priority value="DEBUG"/>
<appender-ref ref="HIBERNATE" />
</category>
<category name="org.hibernate.type">
<priority value="TRACE"/>
<appender-ref ref="HIBERNATE" />
</category>
Adding appenders to a category is "additive" meaning that the new appender is logged to in addition to the existing root appender. You need to explicitly stop it from doing that:
<category name="org.hibernate.SQL">
<priority value="DEBUG"/>
<appender-ref ref="HIBERNATE" additivity="false"/>
</category>
The following setup works for me:
<category name="com.foobar.gearbox" additivity="false">
<priority value="DEBUG" />
<appender-ref ref="GB-FILE" />
</category>
Related
I'm facing an issue with logback for slf4j-api 2.0+ versions, earlier it used to work when I set root logger level to "DEBUG"
Later on, post upgradation to 2.0+ (with logback-classic-1.4.+) I'm unable to print debug statements using root logger.
logback.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="true" scan="true" scanPeriod="60 seconds">
<property scope="system" name="ff_logs" value="${firefly.logging.directory}" />
<include optional="true" file="/etc/firefly.temp/service-logback.xml"/>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>[%d{yyyy-MM-dd'T'HH:mm:ss.SSSZ}] [%thread] %-5level %logger - %msg%n</Pattern>
</layout>
</appender>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${ff_logs}/${app.name}.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>${ff_logs}/${app.name}.log.%i.gz</fileNamePattern>
<minIndex>1</minIndex>
<maxIndex>20</maxIndex>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>20MB</maxFileSize>
</triggeringPolicy>
<encoder>
<pattern>[%d{yyyy-MM-dd'T'HH:mm:ss.SSSZ}] [%thread] %-5level %logger - %msg%n</pattern>
</encoder>
</appender>
<logger name="com.tran.firefly" level="INFO"/>
<logger name="org.apache.activemq.transport" level="WARN"/>
<logger name="com.org.firefly.sessionmanager" level="INFO"/>
<logger name="com.org.apps" level="INFO"/>
<logger name="com.datastax.driver.core.Cluster" level="INFO"/>
<logger name="com.datastax.driver.core.Connection" level="INFO"/>
<logger name="com.datastax.driver.core.Session" level="INFO"/>
<logger name="com.datastax.driver.core.RequestHandler" level="INFO"/>
<logger name="org.apache.kafka.clients.consumer.ConsumerConfig" level="WARN"/>
<logger name="org.apache.kafka.clients.consumer.internals.Fetcher" level="WARN"/>
<logger name="org.apache.kafka.clients.NetworkClient" level="WARN"/>
<logger name="org.apache.kafka.clients.FetchSessionHandler" level="WARN"/>
<logger name="com.org.firefly.crud.initialization.module.PrepareModuleTask" level="WARN"/>
<logger name="io.netty" level="WARN"/>
<root level="DEBUG">
<!-- <appender-ref ref="STDOUT" /> Remove comment markers to log to STDOUT inside the container -->
<appender-ref ref="FILE" />
</root>
</configuration>
Surprisingly getLogger with package name is working, but not with getClass. I got some answer to similar problem, but in play logs. Someone had similar issue with play logs
val log: Logger = LoggerFactory.getLogger(getClass)
my question is: do I have any work around to get application level logs when I set to Debug? Or is there any official announcement of deprecation?
val log: Logger = LoggerFactory.getLogger("com.package.SomeQualified.CanonicalNameHere")
is working, I could see prints. but it is not a viable solution for me. Suggest on this.
Im testing under com.org.firefly.aaa.authorization package
I have tried to upgrade /downgrade slf4j versions. tried with setting static strings in place of getClass.
I'm on Scala 2.12.x Play 2.7.x and as part of my Application Controllers I'm using the logger like this (or equivalently by doing with play.api.Logging):
val logger = play.api.Logger(this.getClass)
and the configuration conf/logback.xml is shown below. The issue is that Application-Controllers' logger.debug(...) statements are not being output in the logs. I assumed that the application was set to DEBUG see one of the lasts entries <logger name="application" level="DEBUG" /> but there is obviously something wrong as the DEBUG statements are not being output?
<!-- https://www.playframework.com/documentation/latest/SettingsLogger -->
<configuration>
<conversionRule conversionWord="coloredLevel" converterClass="play.api.libs.logback.ColoredLevel" />
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>${application.home:-.}/logs/application.log</file>
<encoder>
<pattern>%date [%level] from %logger in %thread - %message%n%xException</pattern>
</encoder>
</appender>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%coloredLevel %logger{15} - %message%n%xException{10}</pattern>
</encoder>
</appender>
<appender name="ASYNCFILE" class="ch.qos.logback.classic.AsyncAppender">
<appender-ref ref="FILE" />
</appender>
<appender name="ASYNCSTDOUT" class="ch.qos.logback.classic.AsyncAppender">
<appender-ref ref="STDOUT" />
</appender>
<logger name="play" level="INFO" />
<logger name="application" level="DEBUG" />
<logger name="slick" level="INFO" />
<logger name="slick.jdbc" level="DEBUG" />
<root level="WARN">
<appender-ref ref="ASYNCFILE" />
<appender-ref ref="ASYNCSTDOUT" />
</root>
</configuration>
PS: I know I can enable DEBUG for everything but then it is too much information I don't need, I'd like to see what's happening with my Controllers' logging.
The logger instantiated with play.api.Logger(this.getClass) inside a class like so
package controller
class HomeController extends ... {
val logger = play.api.Logger(this.getClass)
logger.debug("msg")
}
is not the application logger, but a distinct logger named
controller.HomeController
Thus to specify its log level add the following config to logback.xml
<logger name="controllers" level="DEBUG" />
This makes DEBUG the log level of all classes under controllers package.
Note application logger seems to be deprecated according to docs:
There is also a play.api.Logger singleton object that allows you to
access a logger named application, but its use is deprecated in Play
2.7.0 and above. You should declare your own logger instances...
If the messages are still not logging try changing from async appender to synchronous ones like so:
<root level="WARN">
<appender-ref ref="FILE" />
<appender-ref ref="STDOUT" />
</root>
I have a Play 2.6 application where I let the application log everything to a log file and to the terminal during development. I want all output which is visible on the terminal to be in the log file as well. Occasionally I get messages like this:
[WARN] [04/26/2018 20:06:22.108] [play-dev-mode-akka.actor.default-dispatcher-2] [akka.actor.ActorSystemImpl(play-dev-mode)] Illegal request, responding with status '501 Not Implemented': Unsupported HTTP method: COPY
However I am not able to direct these (I guess Akku logs) to my app.log file. Can anybody help? Here is my logback.xml:
<configuration>
<conversionRule conversionWord="coloredLevel" converterClass="play.api.libs.logback.ColoredLevel" />
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>${application.home:-.}/logs/app.log</file>
<encoder>
<pattern>[%date]: %message%n%xException</pattern>
</encoder>
</appender>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%coloredLevel %logger{15} - %message%n%xException{10}</pattern>
</encoder>
</appender>
<appender name="ASYNCFILE" class="ch.qos.logback.classic.AsyncAppender">
<appender-ref ref="FILE" />
</appender>
<appender name="ASYNCSTDOUT" class="ch.qos.logback.classic.AsyncAppender">
<appender-ref ref="STDOUT" />
</appender>
<logger name="access" level="INFO">
<appender-ref ref="ASYNCFILE" />
</logger>
<!-- Off these ones as they are annoying, and anyway we manage configuration ourselves -->
<logger name="com.avaje.ebean.config.PropertyMapLoader" level="OFF" />
<logger name="com.avaje.ebeaninternal.server.core.XmlConfigLoader" level="OFF" />
<logger name="com.avaje.ebeaninternal.server.lib.BackgroundThread" level="OFF" />
<logger name="com.gargoylesoftware.htmlunit.javascript" level="OFF" />
<root level="INFO">
<appender-ref ref="ASYNCFILE" />
<appender-ref ref="ASYNCSTDOUT" />
</root>
</configuration>
Need help with jboss logging.I am new to jboss application server. I am able to start the application server and i do see in the server log that jboss has started. But when i click on the application and surf around the application that i have deployed i dont see any logging and i am wondering why.I have tried doing this in jboss-log4j.xml
<appender-ref ref="CONSOLE"/>
<priority value="INFO" />
<appender-ref ref="FILE"/>
<priority value="INFO" />
You should create a new appender for your application in log4j.xml:
<appender name="MYAPPENDER" class=""org.jboss.logging.appender.DailyRollingFileAppender">
<errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
<param name="File" value="${jboss.server.log.dir}/filename.log"/>
<param name="Threshold" value="DEBUG"/>
<param name="Append" value="true"/>
<!-- Rollover at midnight each day -->
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
<param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
<!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
<param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
-->
</layout>
And then specify a category after it:
<category name="com.my.package" additivity="false">
<priority value="DEBUG" />
<appender-ref ref="MYAPPENDER"/>
</category>
Where com.my.package is the (top level) package of your application. All classes in this package and its sub-packages will be logged to MYAPPENDER.
I am trying to group logs of multiple related applications to a single log file.
For example I have 3 applications A1.esb, A2.esb, A3.esb.
I want all the logs from these 3 applications get logged to a single log file called A.log.
Similarly, I want B.log for B1.esb, B2.esb and B3.esb.
I am using log4j in JBoss application server.
I have tried to use TCLFilter but I only succeeded in getting individual applications logging to individual log files. As in, A1.esb logging to A1.log, A2.esb logging to A2.log and so on. But I couldn't figure out a way of grouping these loggings.
Thanks a lot guys for your response.
I have managed to fix it by reading some documentation on log4j for jboss.
All I had to do was to specify an appender per application group and inside each appender, I would have a filter chain.
So my log appender shall look like the following.
<appender name="A" class="org.apache.log4j.FileAppender">
<errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"></errorHandler>
<param name="Append" value="false"/>
<param name="File" value="${jboss.server.home.dir}/log/A.log"/>
<param name="Threshold" value="INFO"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
</layout>
<filter class="org.jboss.logging.filter.TCLFilter">
<param name="AcceptOnMatch" value="true"/>
<param name="DeployURL" value="A1.esb"/>
</filter>
<filter class="org.jboss.logging.filter.TCLFilter">
<param name="AcceptOnMatch" value="true"/>
<param name="DeployURL" value="A2.esb"/>
</filter>
<filter class="org.jboss.logging.filter.TCLFilter">
<param name="AcceptOnMatch" value="true"/>
<param name="DeployURL" value="A3.esb"/>
</filter>
<filter class="org.apache.log4j.varia.DenyAllFilter"/>
</appender>
and so on for Group B, which would have B1.esb, B2.esb and B3.esb.
Define an appender you will use for these three logs:
<appender name="A" class="org.jboss.logging.appender.DailyRollingFileAppender">
<errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
<param name="File" value="${jboss.server.log.dir}/A.log"/>
<param name="Append" value="true"/>
<param name="Threshold" value="INFO"/>
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
</layout>
</appender>
Then route your packages to this logger with additivity=false
<category name="A1.esb" additivity="false">
<priority value="INFO"/>
<appender-ref ref="A"/>
</category>
<category name="A2.esb" additivity="false">
<priority value="INFO"/>
<appender-ref ref="A"/>
</category>
<category name="A3.esb" additivity="false">
<priority value="INFO"/>
<appender-ref ref="A"/>
</category>
I hope you are using different packages for each application.