JBoss Enterprise Application Platform - Version 6.1.0.GA adding custom log handler - jboss

I am trying to add a custom log handler to the JBoss Enterprise Application Platform - Version 6.1.0.GA using a tutorial. However, when I add my module to the joboss modules, and update the standalone.xml for the custom log handler and then starting jboss, it crashes.Below is the custom log module.xml and standalone.xml configuration. In the standalone.xml, my custom handler is configured under the custom handler tag.
module.xml
<module xmlns="urn:jboss:module:1.1" name="siteelf.loggers">
<resources>
<resource-root path="SiteElfCustomLogger.jar"/>
<!-- Insert resources here -->
</resources>
<dependencies>
<module name="org.jboss.logging"/>
<module name="javax.api"/>
</dependencies>
</module>
standalone.xml
<subsystem xmlns="urn:jboss:domain:logging:1.2">
<console-handler name="CONSOLE">
<level name="ALL"/>
<encoding value="UTF-8"/>
<formatter>
<pattern-formatter pattern="%d{dd MMM HH:mm:ss} %-5p -- %s%E%n"/>
</formatter>
</console-handler>
<periodic-rotating-file-handler autoflush="true" name="FILE">
<level name="ALL"/>
<encoding value="UTF-8"/>
<formatter>
<pattern-formatter pattern="%d{dd MMM HH:mm:ss} %-5p -- %s%E%n"/>
</formatter>
<file path="server.log" relative-to="jboss.server.log.dir"/>
<suffix value=".yyyy-MM-dd"/>
<append value="true"/>
</periodic-rotating-file-handler>
<custom-handler class="com.org.siteelf.core.log.SiteElfMainLogger" module="siteelf.loggers" name="CustomLogger">
<level name="ERROR"/>
<formatter>
<pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
</formatter>
<file path="server.log" relative-to="jboss.server.log.dir"/>
<properties>
<property name="logFile" value="/usr/share/jboss7/standalone/log/server.log"/>
<property name="debugMode" value="true"/>
</properties>
</custom-handler>
<logger category="com.arjuna">
<level name="OFF"/>
</logger>
<logger category="org.apache.tomcat.util.modeler">
<level name="OFF"/>
</logger>
<logger category="org.jboss.as.config">
<level name="INFO"/>
</logger>
<logger category="sun.rmi">
<level name="INFO"/>
</logger>
<logger category="jacorb">
<level name="OFF"/>
</logger>
<logger category="jacorb.config">
<level name="OFF"/>
</logger>
<root-logger>
<level name="ALL"/>
<handlers>
<handler name="CONSOLE"/>
<handler name="FILE"/>
</handlers>
</root-logger>
</subsystem>

Related

Adding the logg Mode in JBOSS 6.4

I wanted to change the jboss config file so that all logging (application logs and server log) is written to the console when it starts. The current config file (standalone.xml) only makes SERVER logs visible on console , we cannot see Application log.
what should i add to the code to make application logs also visible on console.
<subsystem xmlns="urn:jboss:domain:logging:1.5">
<console-handler name="CONSOLE">
<level name="INFO"/>
<formatter>
<named-formatter name="COLOR-PATTERN"/>
</formatter>
</console-handler>
<periodic-rotating-file-handler name="FILE" autoflush="true">
<formatter>
<named-formatter name="PATTERN"/>
</formatter>
<file relative-to="jboss.server.log.dir" path="server.log"/>
<suffix value=".yyyy-MM-dd"/>
<append value="true"/>
</periodic-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{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>
Thanks

configure wildfly logging for multiple path with only different packages and path

This is my handler:
<periodic-rotating-file-handler name="BATCH_HANDLER">
<level name="DEBUG"/>
<encoding value="UTF-8"/>
<formatter>
<pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] - %s%E%n"/>
</formatter>
<file path="/var/opt/myapp/logs/myapp.log"/>
<suffix value=".yyyy-MM-dd"/>
</periodic-rotating-file-handler>
with following:
<logger category="it.mydomain.mybatch" use-parent-handlers="false">
<handlers>
<handler name="BATCH_HANDLER"/>
</handlers>
</logger>
Now I'd like to have configured new handlers like BATCH_HANDLER with only the file path modified, and then a new logger category with different package.
Something like this:
<logger category="it.mydomain.mybatch.aaa">
<handlers>
<handler name="BATCH_HANDLER_1"/> <!-- inherits from BATCH_HANDLER except the file path -->
</handlers>
</logger>
<logger category="it.mydomain.mybatch.bbb">
<handlers>
<handler name="BATCH_HANDLER_2"/> <!-- inherits from BATCH_HANDLER except the file path -->
</handlers>
</logger>
<logger category="it.mydomain.mybatch.ccc">
<handlers>
<handler name="BATCH_HANDLER_3"/> <!-- inherits from BATCH_HANDLER except the file path -->
</handlers>
</logger>
Is there any way to add handlers that inherit BATCH_HANDLER with only file path changed ?

Logging options for Slick

I'm createing a Play 2.1 app, in which I have decided to use Slick for database interaction.
However I can't find documentation about how to configure/enable logging for Slick.
Anyone knows this?
Slick doesn't do much of any logging above DEBUG level. In application.conf if you add the line:
logger.scala.slick=DEBUG
you're going to get deluged with information from the query compiler.
You're probably just interested in the session information (Connection pool management, query strings, etc). In which case, just add
logger.scala.slick.session=DEBUG
to your Play application's application.conf
For PlayFramework 2.5.0 without Slick
Add to all your database configurations
db.default.logSql=true
Add to your logback.xml file:
<logger name="logger.org.jdbcdslog.StatementLogger" level="INFO" />
All the statements will be logged.
Reference:
https://www.playframework.com/documentation/2.5.x/ScalaDatabase#How-to-configure-SQL-log-statement
For play with Slick 3.0, just use
<logger name="slick.jdbc.JdbcBackend.statement" level="DEBUG" />
To print only select statements, in play-2.2.1 with slick 2.0.0, in application.conf have:
logger.scala.slick.jdbc.JdbcBackend.statement=DEBUG
I'm not using Play at the moment, but configure it as you would use logback. This is a nice description for setting up Play logging.
One option is to add
logger.scala.slick=INFO
to application.conf, as per Play manual. The other, if you have a custom logback.xml, is to add there the following line:
<logger name="scala.slick" level="INFO" />
Slick seems to use slf4j for its logging. So you might want to add a dependency on something like slf4j-simple to your project and set the desired log level for the Slick classes.
I've tried to integrate the logback.xml with the Slick logger but it doesn't work.
Modifing logger.xml (get it the latest version from GitHub based on your version) and adding the slick logger, instead, works.
<configuration>
<conversionRule conversionWord="coloredLevel" converterClass="play.api.Logger$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 %n%message%n%xException%n</pattern>
</encoder>
</appender>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%coloredLevel %logger{15} - %message%n%xException{5}</pattern>
</encoder>
</appender>
<logger name="play" level="INFO" />
<logger name="application" level="DEBUG" />
<!-- Off these ones as they are annoying, and anyway we manage configuration ourself -->
<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" />
<logger name="scala.slick" level="SQL" />
<root level="ERROR">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</root>
</configuration>
For slick 3.1.0, paste this in logback.xml in your resources directory:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<logger name="application" level="DEBUG"/>
<logger name="com.zaxxer.hikari" level="INFO"/>
<logger name="slick" level="INFO"/>
<root level="DEBUG">
<appender-ref ref="STDOUT"/>
</root>
</configuration>
In my case I had to add <logger name="slick" level="INFO"/> to my log4j2.xml file. I'm using Slick 3.0.3 with Spray 1.3.3 and Log4j 2.1

Use my log4j under jboss 6

I want to deploy my web application on JBOSS6. The applicaation itself works, but the logging doens't. I use log4j and have added a jboss-deployment-structure.xml to my war. The contents are
<jboss-deployment-structure>
<deployment>
<!-- Exclusions allow you to prevent the server from automatically adding some dependencies -->
<exclusions>
<module name="org.apache.log4j" />
<module name="org.jboss.logging" />
</exclusions>
</deployment>
In my log4j.xml I have
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "dtd/log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
<appender name="LogAppender" class="org.apache.log4j.RollingFileAppender">
<param name="File" value="C:\\logs\\web.log"/>
<param name="MaxFileSize" value="10000KB"/>
<param name="MaxBackupIndex" value="10"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%x %-5p [%d{yyyyMMdd HH:mm:ss}] - %c:%L - %m%n"/>
</layout>
</appender>
<logger name="be.sofico.web">
<level value="debug" />
<appender-ref ref="LogAppender" />
</logger>
This all works fine on tomcat and websphere (when I set classloading parent last)
How can I get it to work on JBOSS 6?
I solved my problem doing the following:
put jboss-deployment-structure.xml inside web\META-INF with the following in the file
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.apache.log4j" />
<module name="org.apache.commons.logging" />
</exclusions>
</deployment>
</jboss-deployment-structure>
And add this to the startup of the server: -Dorg.jboss.as.logging.per-deployment=false
to set my log4j in the classpath correctly i did 2 things :
1) I set the name of the log4j to use like this
-Dlog4j.configuration=fox-log4j.xml
this one has to be in the CLASSPATH
2) I call the logging manager explicitly otherwise the jboss log4j wont work
this gives in my run.conf :
#parameter used by the JVM and call later in the log4j.xml
LOG_FOLDER=$DIRNAME/../server/default/log
#jvm options
JAVA_OPTS="-Xms256m -Xmx4096m -XX:MaxPermSize=1024m -Dlog4j.configuration=fox-log4j.xml \
-Dfile.encoding=UTF-8 -Dfile.io.encoding=UTF-8 -DjavaEncoding=UTF-8 -Djboss.platform.mbeanserver \
-Djavax.management.builder.initial=org.jboss.system.server.jmx.MBeanServerBuilderImpl \
-Djava.util.logging.manager=org.jboss.logmanager.LogManager \
-Dorg.jboss.logging.Logger.pluginClass=org.jboss.logging.logmanager.LoggerPluginImpl \
-DLOG_FOLDER=$LOG_FOLDER"
now a piece of my log4j :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
<appender name="FOX_LOG" class="org.apache.log4j.RollingFileAppender">
<param name="Threshold" value="DEBUG"/>
<param name="Append" value="true"/>
<param name="MaxFileSize" value="25MB"/>
<param name="MaxBackupIndex" value="5"/>
<param name="File" value="${LOG_FOLDER}/fox.log"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ISO8601} %-15x %t %-5p %-50.50c{1} - %m%n"/>
</layout>
</appender>
<category name="com.mycompany" additivity="true">
<priority value="DEBUG"/>
<appender-ref ref="FOX_LOG"/>
</category>
<root>
<priority value="INFO"/>
<appender-ref ref="FILE"/>
</root>
</log4j:configuration>
hope this could help.
regards
It means it is not loading your log4j.xml. Something wrong with the xml file location or issue with the class loader finding this log4j.xml.

Log4Net in Resharper Unit Test Runner but not in NUnit Unit Runner

I'm using the latest 5.x ReSharper plugin with NUnit 2.5.10. When using Log4Net to log some events for testing purposes the results show up in the ReSharper test window, but do not show up when using NUnit's console unit runner (run as part of our build processes). I've tried giving NUnit a .config file in the same location as the .nunit configuration file with the LogLevelThreshold set to DEBUG, but it still won't log the actual test information to either the output file or the text window in NUnit's GUI. I'm a bit stumped at this point, is there a way to get the two in sync in what's being displayed by test output? Thanks!
Configs in question:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="NUnit">
<section name="TestCaseBuilder" type="System.Configuration.NameValueSectionHandler"/>
<section name="TestRunner" type="System.Configuration.NameValueSectionHandler"/>
</sectionGroup>
</configSections>
<NUnit>
<TestRunner>
<add key="DefaultLogThreshold" value="DEBUG" />
</TestRunner>
</NUnit>
</configuration>
And other config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net debug="false">
<appender name="console" type="log4net.Appender.ConsoleAppender, log4net">
<layout type="log4net.Layout.PatternLayout, log4net">
<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p %c{1}:%L - %m%n" />
</layout>
</appender>
<appender name="DebugAppender" type="log4net.Appender.DebugAppender, log4net">
<layout type="log4net.Layout.PatternLayout, log4net">
<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p %c{1}:%L - %m%n" />
</layout>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="console" />
<!--<appender-ref ref="DebugAppender" />-->
</root>
<logger name="NHibernate">
<level value="INFO" />
</logger>
<logger name="NHibernate.SQL">
<level value="DEBUG" />
</logger>
</log4net>
</configuration>
Thanks in advance for any help.