my application is runnig on jboss 7.3. Log4j configuration file looks
<log4j:configuration debug="true"
xmlns:log4j='http://jakarta.apache.org/log4j/'>
<appender name="fileAppender" class="org.apache.log4j.DailyRollingFileAppender">
<param name="encoding" value="UTF-8" />
<param name="append" value="true" />
<param name="file" value="${jboss.server.log.dir}/mainWS.log" />
<param name="DatePattern" value="'.'yyyy-MM-dd" />
<param name="Threshold" value="DEBUG"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p %d{yyyy-MM-dd HH:mm:ss:SSS} %m rid%X{rid}%n" />
</layout>
</appender>
<appender name="File1" class="org.apache.log4j.DailyRollingFileAppender">
<param name="encoding" value="UTF-8" />
<param name="append" value="true" />
<param name="file" value="${jboss.server.log.dir}/file1.log" />
<param name="DatePattern" value="'.'yyyy-MM-dd" />
<param name="Threshold" value="DEBUG"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p %d{yyyy-MM-dd HH:mm:ss:SSS} %m rid%X{rid}%n" />
</layout>
</appender>
<appender name="File2" class="org.apache.log4j.DailyRollingFileAppender">
<param name="encoding" value="UTF-8" />
<param name="append" value="true" />
<param name="file" value="${jboss.server.log.dir}/file2.log" />
<param name="DatePattern" value="'.'yyyy-MM-dd" />
<param name="Threshold" value="DEBUG"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p %d{yyyy-MM-dd HH:mm:ss:SSS} %m rid%X{rid}%n" />
</layout>
</appender>
<appender name="opTimeFile" class="org.apache.log4j.DailyRollingFileAppender">
<param name="encoding" value="UTF-8" />
<param name="append" value="true" />
<param name="file" value="${jboss.server.log.dir}/opTime.log" />
<param name="DatePattern" value="'.'yyyy-MM-dd" />
<param name="Threshold" value="DEBUG"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p %d{yyyy-MM-dd HH:mm:ss:SSS} %m rid%X{rid}%n" />
</layout>
</appender>
<logger name="debugLogger" additivity="false">
<level value="DEBUG" />
<appender-ref ref="fileAppender" />
</logger>
<logger name="Logger1" additivity="false">
<level value="DEBUG" />
<appender-ref ref="File1" />
</logger>
<logger name="Logger2" additivity="false">
<level value="DEBUG" />
<appender-ref ref="File2" />
</logger>
<logger name="opTimeLogger" additivity="false">
<level value="DEBUG" />
<appender-ref ref="opTimeFile" />
</logger>
<root>
<priority value="OFF" />
</root>
files are created in log directory, but loggin only performed in mainWS.log
I've tried
private static final Logger log = Logger.getLogger("debugLogger");
private static final Logger vLog = Logger.getLogger("Logger1");
private static final Logger eLog = Logger.getLogger("Logger2");
private static final Logger tLog = Logger.getLogger("opTimeLogger");
for (Enumeration loggers= LogManager.getCurrentLoggers(); loggers.hasMoreElements(); ) {
Logger logger = (Logger) loggers.nextElement();
log.debug("logger - " + logger.getName());
vLog.debug("vLogger - " + logger.getName());
eLog.debug("eLogger - " + logger.getName());
tLog.debug("tLogger - " + logger.getName());
for (Enumeration appenders=logger.getAllAppenders(); appenders.hasMoreElements(); ) {
Appender appender = (Appender) appenders.nextElement();
log.debug("appender - " + appender.getName());
vLog.debug("vAppender - " + appender.getName());
eLog.debug("eAppender - " + appender.getName());
tLog.debug("tAppender - " + appender.getName());
}
}
but result is only in mainWS.log file
DEBUG 2014-11-13 10:29:03:125 logger - rid
DEBUG 2014-11-13 10:29:03:138 logger - opTimeLogger rid
DEBUG 2014-11-13 10:29:03:138 logger - Logger1 rid
DEBUG 2014-11-13 10:29:03:138 logger - debugLogger rid
DEBUG 2014-11-13 10:29:03:138 appender - fileAppender rid
DEBUG 2014-11-13 10:29:03:139 logger - Logger2 rid
it seems that only debugLogger has an appender.
Any ideas?
I guess there was a conflict between log4j and the default logging implementation of the application server. I had to exclude the module from your deployment.
I added a WEB-INF/jboss-deployment-structure.xml file
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<!-- Exclusions allow you to prevent the server from automatically adding some dependencies -->
<exclusions>
<module name="org.apache.log4j" />
</exclusions>
</deployment>
I had to include log4j libraries in my application classpath as well.
now it works
My first guess is that log4j reads a different config file than you expect. Check the debug output of log4j when it starts and especially the paths in there.
Related
Any help would be appreciated.
I am using GCP Kubernetes Engine.
Getting following error in POD:
log4net:ERROR XmlHierarchyConfigurator: Cannot find Property [additivity] to set object on [log4net.Appender.RollingFileAppender]
Here is my configuration file:
apiVersion: v1
kind: ConfigMap
metadata:
name: log4net-config
namespace: bold-services
data:
Log4Net.config: |
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<log4net threshold="ALL" debug="true">
<root>
<level value="ALL" />
<!-- <appender-ref ref="ConsoleAppender" /> -->
<appender-ref ref="FILE_DEBUG_APPENDER" />
<appender-ref ref="FILE_ERROR_APPENDER" />
</root>
<!-- === File Appender for NON-ERROR messages file === -->
<appender name="FILE_DEBUG_APPENDER" type="log4net.Appender.RollingFileAppender" class="ch.qos.logback.classic.AsyncAppender">
<file type="log4net.Util.PatternString" value="%property{AppDataPath}/logs/%property{loggername}/debug-info-%env{HOSTNAME}.txt" />
<filter type="log4net.Filter.LevelMatchFilter">
<levelToMatch value="INFO" />
</filter>
<filter type="log4net.Filter.DenyAllFilter" />
<additivity value="true" />
<appendToFile value="true" />
<maxSizeRollBackups value="1" />
<maximumFileSize value="300KB" />
<rollingStyle value="Size" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<header type="log4net.Util.PatternString" value="#Software: %property{loggername} %newline#Date: %date %newline#Fields: date thread namespace methodname message %newline" />
<conversionPattern value="%date [%thread] %message%newline" />
</layout>
</appender>
<!-- === File Appender for ERROR messages file === -->
<appender name="FILE_ERROR_APPENDER" type="log4net.Appender.RollingFileAppender" class="ch.qos.logback.classic.AsyncAppender">
<file type="log4net.Util.PatternString" value="%property{AppDataPath}/logs/%property{loggername}/errors-%env{HOSTNAME}.txt" />
<filter type="log4net.Filter.LevelMatchFilter">
<levelToMatch value="ERROR" />
</filter>
<filter type="log4net.Filter.DenyAllFilter" />
<additivity value="true" />
<appendToFile value="true" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="100KB" />
<rollingStyle value="Size" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<header type="log4net.Util.PatternString" value="#Software: %property{loggername} %newline#Date: %date %newline#Fields: date thread namespace methodname message %newline" />
<conversionPattern value="%date [%thread] %-5level %message%newline" />
</layout>
</appender>
<!-- === Console Appender to use in BufferingForwardingAppender === -->
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern type="log4net.Util.PatternString" value="%newline%%-5level %property{loggername} %env{HOSTNAME} %%date [%%thread] %%message%newline" />
</layout>
</appender>
</log4net>
</configuration>
We have a Magnolia CMS 5.5 Setup with an PostgreSQLPersistence Manager. I was investigating a case where our security config did not work as expected. I found out that our workspace/repository config was missing these three lines:
<WorkspaceSecurity>
<AccessControlProvider class="info.magnolia.cms.core.MagnoliaAccessProvider" />
</WorkspaceSecurity>
Is there there a way to recreate the existing workspaces including this config or is there only the possibility to export and reimport the data into a fresh install (which is in our case going to take very long)?
Edit:
It worked for my local system, when i used the following repo-conf.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Repository PUBLIC "-//The Apache Software Foundation//DTD Jackrabbit 1.5//EN"
"http://jackrabbit.apache.org/dtd/repository-1.5.dtd">
<Repository>
<FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
<param name="path" value="${rep.home}/repository" />
</FileSystem>
<Security appName="magnolia">
<SecurityManager class="org.apache.jackrabbit.core.DefaultSecurityManager"/>
<AccessManager class="org.apache.jackrabbit.core.security.DefaultAccessManager">
</AccessManager>
<!-- login module defined here is used by the repo to authenticate every request. not by the webapp to authenticate user against the webapp context (this one has to be passed before thing here gets invoked -->
<LoginModule class="info.magnolia.jaas.sp.jcr.JackrabbitAuthenticationModule">
</LoginModule>
</Security>
<DataStore class="org.apache.jackrabbit.core.data.FileDataStore">
<param name="path" value="${rep.home}/repository/datastore"/>
<param name="minRecordLength" value="1024"/>
</DataStore>
<Workspaces rootPath="${rep.home}/workspaces" defaultWorkspace="default" />
<Workspace name="default">
<FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
<param name="path" value="${wsp.home}/default" />
</FileSystem>
<PersistenceManager class="org.apache.jackrabbit.core.persistence.bundle.PostgreSQLPersistenceManager">
<param name="driver" value="org.postgresql.Driver"/>
<param name="url" value="jdbc:postgresql://xxxxx" />
<param name="databaseType" value="postgresql" /><!-- warning, this is not the schema name, it's the db type -->
<param name="user" value="xxxxx" />
<param name="password" value="xxxxxx" />
<param name="schemaObjectPrefix" value="${wsp.name}_" />
<param name="externalBLOBs" value="false" />
</PersistenceManager>
<SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
<param name="path" value="${wsp.home}/index" />
<param name="useCompoundFile" value="true" />
<param name="minMergeDocs" value="100" />
<param name="volatileIdleTime" value="3" />
<param name="maxMergeDocs" value="100000" />
<param name="mergeFactor" value="10" />
<param name="maxFieldLength" value="10000" />
<param name="bufferSize" value="10" />
<param name="cacheSize" value="1000" />
<param name="forceConsistencyCheck" value="false" />
<param name="autoRepair" value="true" />
<param name="analyzer" value="org.apache.lucene.analysis.standard.StandardAnalyzer" />
<param name="queryClass" value="org.apache.jackrabbit.core.query.QueryImpl" />
<param name="respectDocumentOrder" value="true" />
<param name="resultFetchSize" value="2147483647" />
<param name="extractorPoolSize" value="3" />
<param name="extractorTimeout" value="100" />
<param name="extractorBackLogSize" value="100" />
<!-- needed to highlight the searched term -->
<param name="supportHighlighting" value="true"/>
<!-- custom provider for getting an HTML excerpt in a query result with rep:excerpt() -->
<param name="excerptProviderClass" value="info.magnolia.jackrabbit.lucene.SearchHTMLExcerpt"/>
</SearchIndex>
<WorkspaceSecurity>
<AccessControlProvider class="info.magnolia.cms.core.MagnoliaAccessProvider" />
</WorkspaceSecurity>
</Workspace>
<Versioning rootPath="${rep.home}/version">
<FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
<param name="path" value="${rep.home}/workspaces/version" />
</FileSystem>
<PersistenceManager class="org.apache.jackrabbit.core.persistence.bundle.PostgreSQLPersistenceManager">
<param name="driver" value="org.postgresql.Driver"/>
<param name="url" value="jdbc:postgresql://xxxxxx" />
<param name="schema" value="postgresql" /><!-- warning, this is not the schema name, it's the db type -->
<param name="user" value="xxxxxxxx" />
<param name="password" value="xxxxxxxx" />
<param name="schemaObjectPrefix" value="version_" />
<param name="externalBLOBs" value="false" />
</PersistenceManager>
</Versioning>
</Repository>
Here removing/adding the WorkspaceSecurity works.
But on the relevant system we have another config where adding the WorkspaceSecurity does not work:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Repository PUBLIC "-//The Apache Software Foundation//DTD Jackrabbit 1.5//EN"
"http://jackrabbit.apache.org/dtd/repository-1.5.dtd">
<Repository>
<FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
<param name="path" value="${rep.home}/repository" />
</FileSystem>
<Security appName="Jackrabbit">
<AccessManager class="org.apache.jackrabbit.core.security.SimpleAccessManager"></AccessManager>
<LoginModule class="org.apache.jackrabbit.core.security.SimpleLoginModule">
<param name="yyyyyyy" value="yyyyyyy" />
</LoginModule>
</Security>
<DataStore class="org.apache.jackrabbit.core.data.FileDataStore">
<param name="path" value="${rep.home}/repository/datastore"/>
<param name="minRecordLength" value="1024"/>
</DataStore>
<Workspaces rootPath="${rep.home}/workspaces" defaultWorkspace="default" />
<Workspace name="default">
<FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
<param name="path" value="${wsp.home}/default" />
</FileSystem>
<PersistenceManager class="org.apache.jackrabbit.core.persistence.bundle.PostgreSQLPersistenceManager">
<param name="driver" value="org.postgresql.Driver"/>
<param name="url" value="jdbc:postgresql://xxxxxxx" />
<param name="schema" value="postgresql" /><!-- warning, this is not the schema name, it's the db type -->
<param name="user" value="xxxxxxxx" />
<param name="password" value="xxxxxxxx" />
<param name="schemaObjectPrefix" value="${wsp.name}_" />
<param name="externalBLOBs" value="false" />
</PersistenceManager>
<SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
<param name="path" value="${wsp.home}/index" />
<param name="useCompoundFile" value="true" />
<param name="minMergeDocs" value="100" />
<param name="volatileIdleTime" value="3" />
<param name="maxMergeDocs" value="100000" />
<param name="mergeFactor" value="10" />
<param name="maxFieldLength" value="10000" />
<param name="autoRepair" value="true" />
<param name="analyzer" value="org.apache.lucene.analysis.standard.StandardAnalyzer" />
<param name="queryClass" value="org.apache.jackrabbit.core.query.QueryImpl" />
<param name="respectDocumentOrder" value="true" />
<param name="resultFetchSize" value="2147483647" />
<param name="extractorPoolSize" value="3" />
<param name="extractorTimeout" value="100" />
<param name="extractorBackLogSize" value="100" />
<!-- needed to highlight the searched term -->
<param name="supportHighlighting" value="true"/>
<!-- custom provider for getting an HTML excerpt in a query result with rep:excerpt() -->
<param name="excerptProviderClass" value="info.magnolia.jackrabbit.lucene.SearchHTMLExcerpt"/>
</SearchIndex>
</Workspace>
<Versioning rootPath="${rep.home}/version">
<FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
<param name="path" value="${rep.home}/workspaces/version" />
</FileSystem>
<PersistenceManager class="org.apache.jackrabbit.core.persistence.bundle.PostgreSQLPersistenceManager">
<param name="driver" value="org.postgresql.Driver"/>
<param name="url" value="jdbc:postgresql://xxxxxxxxx" />
<param name="schema" value="postgresql" /><!-- warning, this is not the schema name, it's the db type -->
<param name="user" value="xxxxx" />
<param name="password" value="xxxxxxx" />
<param name="schemaObjectPrefix" value="version_" />
<param name="externalBLOBs" value="false" />
</PersistenceManager>
</Versioning>
</Repository>
Using the first config on the relevant system leads to lots of errors in the log. Do you have an idea how to solve this?
Thanks, Reencode
You can copy existing workspaces using Workspace API but this doesn't help you. You can export the rootNode and import it to a fresh install which as you mentioned will take a lot of time as well. However, I'm a bit puzzled with accessControlProvider class configuration because it should be just working fine when one adds it to the configuration and restarts the instance. This is because the permission checks are done in the runtime and shouldn't affect it in a way that changing class has no effect whatsoever. I'd suggest checking this first and if still for some reason things don't work, then I'd check RepositoryCopier API and maybe there is a way to set that class while calling
RepositoryCopier.copy();
Cheers,
I have one Activator project, the controllers which i have written for that i am able to log into seprate file. Now i have some JS file which contains some logging statments too which i want to store in same log file.
Application.java sample
public static Result index() throws Exception {
Logger.of(LoggerConstants.OTNlogger).debug(LoggerConstants.methodEntry);
// CommonUtils.createDBConnection();
if (isSessionExist()) {
Logger.of(LoggerConstants.OTNlogger).debug(
LoggerConstants.returnObj + LoggerConstants.loggerSpace);
Logger.of(LoggerConstants.OTNlogger).debug(
LoggerConstants.methodExit);
return ok(tool.render());
} else {
Logger.of(LoggerConstants.OTNlogger).debug(LoggerConstants.methodExit);
return badRequest(main.render());
}
}
Logger.xml
<configuration debug="true">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder
by default -->
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<appender name="FILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>logFile.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover -->
<fileNamePattern>logFile.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- keep 1 days' worth of history -->
<maxHistory>5</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%caller{2} : %r] %p %logger{0} - %msg %n</pattern>
<!-- time, [caller level : excution time of method], level, loggerName, - message -->
</encoder>
</appender>
<logger name="ODE" level="TRACE" additivity="false">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</logger>
<logger name="play" level="INFO" additivity="false">
<appender-ref ref="STDOUT" />
</logger>
<root level="info" additivity="false">
<appender-ref ref="STDOUT" />
</root>
LogFile.log sample
15:58:22.491 [Caller+0 at play.Logger$ALogger.debug(Logger.java:332)
Caller+1 at com.egnaro.utils.CommonUtils.createDBConnection(CommonUtils.java:30)
: 81754] DEBUG ODE - Entered into method
15:58:22.512 [Caller+0 at play.Logger$ALogger.info(Logger.java:361)
Caller+1 at com.egnaro.utils.CommonUtils.createDBConnection(CommonUtils.java:33)
: 81775] INFO ODE - Morphia Object Intilizing
15:58:22.927 [Caller+0 at play.Logger$ALogger.info(Logger.java:361)
Caller+1 at com.egnaro.utils.CommonUtils.createDBConnection(CommonUtils.java:46)
: 82190] INFO ODE - Databse created
sample.js
function inputEditor(data, event){
var treeView = $("#tree").data("kendoTreeView");
var selectedNode = treeView.select(),
dataItem = treeView.dataItem(selectedNode);
//var span = $(this).find('.k-sprite').hide();
//var span = $(this).find('.k-sprite').detach();
$target = $(event.target);
$target.editable(function (value, settings)
{
console.log(this);
return value;
},
{
submit:'ok',
event: 'dblclick',
cssclass: 'editableTree'
});
//return;
//$(this).find('.k-sprite').append(span);
$target.trigger('dblclick', [event]);
//$(this).find('.k-sprite').append(span);
}
I want to store log for console.log() in my loggerfile. Please give step by step explanation, i'm new in playframework.
I have setup gwt remote logging based on the gwt documentation, however my logs are going to System.out instead of being written to a log file.
My gwt module looks like:
<module rename-to='ezdappserver'>
<inherits name="com.google.gwt.logging.Logging"/>
<set-property name="gwt.logging.simpleRemoteHandler" value="ENABLED" />
<set-property name="gwt.logging.logLevel" value="FINEST"/>
<set-property name="gwt.logging.enabled" value="TRUE"/>
<set-property name="gwt.logging.consoleHandler" value="ENABLED" />
<set-property name="gwt.logging.popupHandler" value="DISABLED" />
</module>
My servlet definition is setup like:
<servlet>
<servlet-name>remoteLogging</servlet-name>
<servlet-class>com.google.gwt.logging.server.RemoteLoggingServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>remoteLogging</servlet-name>
<url-pattern>/ezdappserver/remote_logging</url-pattern>
</servlet-mapping>
When an error is logged I see output in my console like so:
Mar 26, 2014 2:10:36 PM com.google.gwt.logging.server.RemoteLoggingServiceUtil logOnServer
SEVERE: Exception caught: (NotFoundError)
....Rest of error....
I was expecting this output to be written to a log file somewhere in my war. Also, I would really like to be able to specify where this file is located, however I haven't been able to find any documentation on that either.
Any help would be much appreciated.
NOTE: I am not running this through dev mode, this is with compiled code.
Thanks!
Try below options also in gwt.xml based on your requirement:
<!-- This handler sends log messages to the server, where they will be logged using the server side logging mechanism. -->
<set-property name="gwt.logging.simpleRemoteHandler" value="ENABLED" />
<!-- Logs by calling method GWT.log. These messages can only be seen in Development Mode in the DevMode window. -->
<set-property name="gwt.logging.developmentModeHandler" value="ENABLED" />
<!-- These messages can only be seen in Development Mode in the DevMode window. -->
<set-property name="gwt.logging.systemHandler" value="ENABLED" />
<!-- Logs to the popup which resides in the upper left hand corner of application when this handler is enabled. -->
<set-property name="gwt.logging.popupHandler" value="DISABLED" />
<!-- Logs to the javascript console, which is used by Firebug Lite (for IE), Safari and Chrome. -->
<set-property name="gwt.logging.consoleHandler" value="DISABLED"/>
<!-- Logs to the firebug console. -->
<set-property name="gwt.logging.firebugHandler" value="DISABLED" />
If above configuration are still not working for you then try below code along with above configuration.
Add log4j.xml file to define the log file location with log level
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="DT=> %d [%.4t] %-5p %c{1} - %m%n" />
</layout>
</appender>
<appender name="SERVER_FILE_LOG" class="org.apache.log4j.RollingFileAppender">
<param name="File" value="${jboss.server.log.dir}/logs/DataTools_Server.log" />
<param name="Append" value="true" />
<param name="MaxFileSize" value="5MB" />
<param name="MaxBackupIndex" value="10" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d [%.4t] %-5p [%c] %m%n" />
</layout>
</appender>
<appender name="CLIENT_FILE_LOG" class="org.apache.log4j.RollingFileAppender">
<param name="File" value="${jboss.server.log.dir}/logs/DataTools_Client.log" />
<param name="Append" value="true" />
<param name="MaxFileSize" value="5MB" />
<param name="MaxBackupIndex" value="10" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d [%.4t] %-5p %m%n" />
</layout>
</appender>
<category name="com.x.y.server">
<priority value="DEBUG" />
<appender-ref ref="SERVER_FILE_LOG" />
<appender-ref ref="STDOUT" />
</category>
<category name="gwtRemoteLogging">
<priority value="ERROR" />
<appender-ref ref="CLIENT_FILE_LOG" />
</category>
<root>
<priority value ="ERROR" />
<appender-ref ref="SERVER_FILE_LOG" />
</root>
</log4j:configuration>
Define you own logging servlet by implementing RemoteLoggingService
import java.util.logging.Level;
import java.util.logging.LogRecord;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import com.google.gwt.logging.server.StackTraceDeobfuscator;
import com.google.gwt.logging.shared.RemoteLoggingService;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import org.apache.log4j.Logger;
/**
* The Class GwtRemoteLogging.
*/
#SuppressWarnings("serial")
public class GwtRemoteLogging extends RemoteServiceServlet implements RemoteLoggingService {
/** The Constant logger. */
private StackTraceDeobfuscator deobfuscator = null;
private final static Logger logger = Logger.getLogger("gwtRemoteLogging");
#Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
}
/**
* Logs a Log Record which has been serialized using GWT RPC on the server.
*
* #return either an error message, or null if logging is successful.
*/
public final String logOnServer(LogRecord lr) {
try {
if (lr.getLevel().equals(Level.SEVERE)) {
logger.error(lr.getMessage(),lr.getThrown());
} else if (lr.getLevel().equals(Level.INFO)) {
logger.info(lr.getMessage(),lr.getThrown());
} else if (lr.getLevel().equals(Level.WARNING)) {
logger.warn(lr.getMessage(),lr.getThrown());
} else if (lr.getLevel().equals(Level.FINE)) {
logger.debug(lr.getMessage(),lr.getThrown());
} else {
logger.trace(lr.getMessage(),lr.getThrown());
}
} catch (Exception e) {
logger.error("Remote logging failed", e);
return "Remote logging failed, check stack trace for details.";
}
return null;
}
/**
* By default, this service does not do any deobfuscation. In order to do server side
* deobfuscation, you must copy the symbolMaps files to a directory visible to the server and
* set the directory using this method.
*
* #param symbolMapsDir
*/
public void setSymbolMapsDirectory(String symbolMapsDir) {
if (deobfuscator == null) {
deobfuscator = new StackTraceDeobfuscator(symbolMapsDir);
} else {
deobfuscator.setSymbolMapsDirectory(symbolMapsDir);
}
}
}
web.xml
<servlet>
<servlet-name>remoteLogServlet</servlet-name>
<servlet-class>com.x.y.server.servlet.GwtRemoteLogging</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>remoteLogServlet</servlet-name>
<url-pattern>/ezdappserver/remote_logging</url-pattern>
</servlet-mapping>
The RemoteServiceServlet uses java.util.logging to log, and by default it logs to the console (System.err, not System.out BTW).
If you want to log to a file, then you have to configure java.util.logging; either editing your global lib/logging.properties (not recommended), using your own config file that you pass to the JVM using the java.util.logging.config.file system property, or programmatically.
Depending on your servlet container, it can be configured by different means. For instance, Tomcat will read a logging.properties file in your WEB-INF/classes: http://tomcat.apache.org/tomcat-7.0-doc/logging.html#Using_java.util.logging_(default)
I'm unable to append messages from my application to the JBoss console. The following are the changes that I made to the jboss-log4j.xml configuration file:
<category name="com.tricubes">
<priority value="INFO"/>
<appender-ref ref="CONSOLE"/>
</category>
Here is my code:
public class OneToOneValidation2 {
private static final Logger logger = Logger.getLogger("com.tricubes");
public boolean validate(byte[] fpImage, byte[] fpTemplate, String desc, String ticket) {
...
logger.info("BES INFO: SOCKET MSG SENT " + intToByteArray(x));
...
return b;
}
}
What am I missing?
TIA!
Edited:
The console appender. Also is the default appender used by JBoss.
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
<param name="Target" value="System.out"/>
<param name="Threshold" value="INFO"/>
<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
</layout>
I have tried with both org.jboss.logging.Logger and org.apache.log4j.Logger;
Category is deprecated (use Logger), and Priority is not recommended (use Level). So your config block should be:
<logger name="com.tricubes">
<level value="INFO"/>
<appender-ref ref="CONSOLE"/>
</logger>
Also, what is your CONSOLE appender defined as? If its not pointing at the JBoss console, it wont log there.