GoogleAppEngine log warning - java

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

Related

How to see org.codehaus.jackson log messages - using logging.properties

I am trying to deserialize incoming PUT request with JSON request body using org.codehaus.jackson package and I am receiving error message The request sent by the client was syntactically incorrect. How can I get more detailed log/error messages in my Pivotal TC server logs, e.g. in catalina.log?
I have added the following line to logging.properties:
org.codehaus.level = FINEST
But NO messages from org.codehaus is displayed in my log, although the error message is displayed on web page. Maybe codehaus does not support Java logging and I should configure J4Log or similar another logging facility?
My Jackson version is 1.9.13, I am using Pivotal tc server from Spring Tools Suite (3.8).
For what you say it seems that you're trying to change the tomcat logging.properties.
That's usually a bad idea as you may want different logging on different webApps loaded in the same Tomcat server.
What you should do is configure the log4j in your project.
Usually Java projects define a "resource" folder. You should add in there a file called
log4j.properties
and add in there the following:
log4j.rootLogger=ERROR,stdout
# Logger for jackson lib
log4j.logger.org.codehaus=TRACE
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%p\t%d{ISO8601}\t%r\t%c\t[%t]\t%m%n
This is extracted from the default log4j configuration and will log in the standard output that for Tomcat is redirected to the catalina.out log file.
You may want to read the documentation at https://docs.oracle.com/cd/E29578_01/webhelp/cas_webcrawler/src/cwcg_config_log4j_file.html
explaining how to redirect the logging to a different file and how to use rolling appenders so you keep some history
Hopefully this will work!
The request sent by the client was syntactically incorrect
^^^ This message is created by the HTTP servlet processing the client request and not by the jackson mapper.
You could find the related log messages under spring-mvc logger name: org.springframework.web.

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.

I need separate my apllication logging from the server.log

I want my application has its own logging configuration. I want to separate my logs from the server.log file. i am using jboss 7 and log4j. And please tell me how i configure my jboss 7 with my log4j and using struts2 framwork.
Read up about Log4J appenders. The general idea is you'd have an appender that would capture all logging under a specific package, preventing it from being outputted into server.log
Here is a reasonable answer that would help - log4j: Log output of a specific class to a specific appender

log4j generating logger file but not appending anything

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?

Interweave events from using WebLogic and Log4j

I am using WebLogic and Log4j for my Struts application. Since Action class is not thread-safe, I assumed Action classes are cached by WebLogic and re-used for every HTTP request.
In this case, if there are multiple clients accessing the same Action class, I assume the events printed on by Log4j will be output by multiple request.
The log information would not be sequential and very difficult to interpret.
How do I resolve such issues?
First, I would like to fix some terms usage in your question. Struts is a MVC framework. Weblogic is a Java EE container. The Action functionality and life cycle does not depend on container. It is the Struts's functionality only.
You are right, since instance of Action is created per request your log will contain a mixture of log messages created by different actions.
The typically used solution is to print thread name into log (log4j supports this configuration), then use grep command on unix or find on windows to filter only relevant messages.
Here is an example of layout configuration that causes log4j to print thread name:
<layout class="org.apache.log4j.EnhancedPatternLayout">
<param name="ConversionPattern" value="%-5p %-23d{ISO8601}{GMT} [%t] %x: %c{1}(%C{1}.%M:%L) - %m%n"/>
</layout>
[%t] does the job.

Categories