log4j generating logger file but not appending anything - java

The settings I have specified in log4j is as follows:
log4j.appender.F2=org.apache.log4j.RollingFileAppender
log4j.appender.F2.File=E\:/Documentum/logs/dflogger.log
log4j.appender.F2.MaxFileSize=10MB
log4j.appender.F2.layout=org.apache.log4j.PatternLayout
log4j.appender.F2.layout.ConversionPattern=%d{ABSOLUTE} %5p [%t] %c - %m%n
log4j.logger.com.myorg.mytbo.tbo=DEBUG,F2
I am trying to log information from inside TBO (defined in package com.myorg.mytbo.tbo) which is essentially a JAR deployed on jboss application server inside EMC Documentum Content Server. This specific information about Documentum server shouldn't be any concern since it still uses org.apache.log4j. When the TBO runs it creates dflogger.log but does not append any information inside it.
I suspect many reasons like:
File is getting created in readonly mode.
or may be there is some issue associated with logging for com.myorg.mytbo.tbo, for which this is somewhat similar thread, specifying PARENT_FIRST option in websphere. But I am using jboss, so if the issue is similar then can anyone tell if I need to modify jboss settings?

Related

log4j issues, or jboss issues. i almost gave up

I have the following situation:
- two HA singleton apps on jboss eap
- each one with its own log4j.properties file:
App1:
log4j.rootLogger=DEBUG, App1
log4j.appender.App1=org.apache.log4j.RollingFileAppender
log4j.appender.App1.append=true
log4j.appender.App1.File=${jboss.server.log.dir}/App1.log
log4j.appender.App1.MaxFileSize=10MB
log4j.appender.App1.MaxBackupIndex=10
log4j.appender.App1.threshold=TRACE
log4j.appender.App1.layout=org.apache.log4j.PatternLayout
log4j.appender.App1.layout.ConversionPattern=[%-5p] [%t] %d{yyyy MMM dd HH:mm:ss,SSS} (%C:%F:%L) - %m%n
log4j.logger.org.hibernate=DEBUG, App1
log4j.logger.com.arjuna=DEBUG, App1
log4j.logger.com.sun=ERROR,App1
log4j.logger.com.sun.xml.ws.transport.http.client.HttpTransportPipe=DEBUG,App1
App2
log4j.rootLogger=DEBUG, App2
log4j.appender.App2=org.apache.log4j.RollingFileAppender
log4j.appender.App2.append=true
log4j.appender.App2.File=${jboss.server.log.dir}/App2.log
log4j.appender.App2.MaxFileSize=10MB
log4j.appender.App2.MaxBackupIndex=10
log4j.appender.App2.threshold=TRACE
log4j.appender.App2.layout=org.apache.log4j.PatternLayout
log4j.appender.App2.layout.ConversionPattern=[%-5p] [%t] %d{yyyy MMM dd HH:mm:ss,SSS} (%C:%F:%L) - %m%n
log4j.logger.org.hibernate=DEBUG, App2
log4j.logger.com.arjuna=DEBUG, App2
log4j.logger.com.sun=ERROR,App2
log4j.logger.com.sun.xml.ws.transport.http.client.HttpTransportPipe=DEBUG,App2
both installed and running quite hmmm... with this issue:
All hibernate logs form App2 are written in App1.log
Also all com.sun.xml... logs from App2 are written in App1.log.
And non (nor hibernate nor sun.xml) are written into App2.log.
Both org.hibernate and com.sun are log managed into applications, at server level they are on ERROR level, so there is no logging in server.log.
Also, if I’m disabling App1, those two categories from App2 will be logged into the App1's log file.
It clearly is something I miss and/or I really don't know.
Now, my problem is that I need log4j to log stuff only where I’m telling it to do it.
Can anyone advise me with anything? And, hmm, I really don’t like the idea of using jboss logging settings (custom appenders in console or standalone-ha.xml).
I just want to use log4j…
Thanks to all.
Hibernate is shipped with JBoss (under modules\system\layers\base\org\hibernate) and uses internally org.jboss.logging. And org.jboss.logging is also shipped with JBoss. Hence I guess that logging initialization is only done once for the complete JVM (as org.jboss.logging is loaded through the module classloader and not through your application class loaders and static fields are classloader specific).
I would recommend (although your requirements sounds strange to me), to ship Hibernate and log4j in your application (i.e. in the lib/ folder of your applications). Then Hibernate is loaded twice, one time by the classloader for the first application and a second time by the classloader for the second application. This way the static field can exist twice.

log4j writes to Systemerr.log on Websphere (configuration from java )

I have a web application, which uses log4j and slf4j as facade for logging. Logging is configured not from log4j.properties file, but from Java code.
Application is running on three different machines using Websphere Application Server.
Issue is that on two instances logging works as expected. But on the third one nothing is written in my logfile. Output goes to SystemErr.log instead (there are messages of ERROR and INFO levels).
Initially I thought that something is with Websphere server configuration, but later I found this link http://www.webagesolutions.com/knowledgebase/waskb/waskb004/ which says that such situation can be when log4j.properties can not be read.
But I am not using property file for this. And configuration form Java works OK on other two instances.
Any ideas what can be the issue?
Thank you in advance!
Please make sure that no alternative slf4j binding (such as simple) exists on the CLASSPATH.

Effectively debugging Log4j framework

I wanted to implement logging for my web services.I have been playing around with Log4j. It's a really cool logging framework when it works.But when it doesn't , it's a pain to debug.
My problem is that i am trying to log to the database , but for some reason I don't see anything being logged to the table. I have no clue whats causing this.
In my log4j.xml i have the following line
<log4j:configuration debug="true"
xmlns:log4j='http://jakarta.apache.org/log4j/'>
But when i deploy and run my web service in the debug mode in Eclipse , I don't see logging related debug statements on the console.
I want to be able to see
log4j initializing and configuring the loggers. So if anything is wrong with my xml configuration i would know immediately.
log4j logging to the destination , in this case to the database. If there is a some kind of a sql/database exception I would know.
I am logging at the application level (the application is using its own log4j jar and configuration files as opposed to using the application servers logging mechanism)
My project uses log4j-1.2.17 , Eclipse Luna 4.4.0, JBoss EAP 6.4.0.
Can our log4j experts suggest ways to effectively debug log4j itself. Are there Eclipse plugins that can help alleviate the pain.

Multiple log4j.xml in a jar files

I am developing a client api where I have a specific requirement to log the client api specific log messages to a separate file and it is pretty straight forward: I created an appender and associated the appender with logger which is specific to my package.
Now the question is:
What happens if the client application has its own log4j.xml? How will my appender and logger work in that environment ?
The log4j initialization process only handles one configuration file - thus this file should contain all logging configuration that should be active. You probably have to define a specific configuration for the client application that contains your and the client applications logging configuration.
The client application has to be configured to use this file for the initialization. This is done by setting the log4j.configuration system property as described in the log4j manual (suppose that you are using log4j 1).

GoogleAppEngine log warning

I create a default project using GoogleAppEngine for java, and when I deploy my application on google server I have the following warning message for the first request.
log4j:WARN No appenders could be found for logger (DataNucleus.Connection).
log4j:WARN Please initialize the log4j system properly.
The log is working fine, but some request are delayed by this problem.
How can I configure it correctly?
What makes you sure that this is delaying some of your requests?
GAE does not function like a standard servlet container. Behind the scenes it unloads any webapps that are idle, and then loads them in again only when it gets a new request for that webapp. This is basically equivalent to doing a complete redeploy of your application, and it doesn't even begin until after GAE has received the request. Thus any request that triggers a load operation will be noticeably delayed compared to subsequent requests.
But there are a whole lot of things going on that are contributing to the delay, and I think an uninitialized log4j setup is not making much of an actual difference.
This messages means that there is no log4j configuration is found.
You have to put an configuration for log4j, for example into file named as log4j.properties in app classpath.
Configuration, for example, would be:
log4j.rootLogger=WARN, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %t %c{1}:%M:%L - %m%n
If your project is Maven based, then the best place to put log4j.properties will be src/main/resources

Categories