Adding the logg Mode in JBOSS 6.4 - jboss

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

Related

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 ?

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

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>

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

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.

How to setup Binding redirect with Nunit's gui runner?

I am trying to run my unit tests with nHibernate 3 and fluentnHibernate, To do this I need to setup a assembly binding redirect so fluentnHibernate will work with the new version of nHibernate. I have tried to update my test project's app.config however the testdriven.net runner and the nunit gui runner don't seem to read these settings.
below is my test.dll's app.config.
<configuration>
<configSections>
<!-- Others sections -->
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
</configSections>
<connectionStrings>
<add name="Test" connectionString="Data Source=SQL2008, 1080;Initial Catalog=TestCOM;Integrated Security=True"/>
</connectionStrings>
<log4net>
<appender name="GeneralLog" type="log4net.Appender.RollingFileAppender">
<file value="Logs.txt"/>
<appendToFile value="true"/>
<maximumFileSize value="100KB"/>
<rollingStyle value="Size"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%d{HH:mm:ss} [%t] %-5p %c - %m%n"/>
</layout>
</appender>
<logger name="NHibernate.SQL" additivity="false">
<level value="DEBUG"/>
<appender-ref ref="GeneralLog"/>
</logger>
</log4net>
<startup useLegacyV2RuntimeActivationPolicy="true">
<requiredRuntime version="v4.0.30319" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<qualifyAssembly
partialName="System.Data.SqlServerCe"
fullName="System.Data.SqlServerCe,
Version=3.5.1.0, Culture=neutral,
PublicKeyToken=89845dcd8080cc91"/>
<dependentAssembly>
<assemblyIdentity name="NHibernate"
publicKeyToken="AA95F207798DFDB4"
culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-3.0.0.1001"
newVersion="3.0.0.1001"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
I am getting the following error:
TestCase 'FieldGuideTests.Service.SchemaFacts.Can_Build_SQL_Schema'
failed: System.IO.FileLoadException : Could not load file or assembly 'NHibernate, Version=2.1.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at FieldGuideService.SessionFactoryManagers.SQL_SessionFactoryManager.CreateSessionFactory()