Is there any way to log all the icefaces logs? - jsf

Our view layer are made from JSF 2.1.4,Icefaces 3.3.When we are starting our application we are able to see all the logs in eclipse console is there any way to log all the icefaces logs into a file .
# configure the ice-faces logging
log4j.appender=org.apache.log4j.RollingFileAppender
log4j.appender.File=D:/icefaces.log
log4j.appender.layout=org.apache.log4j.PatternLayout
log4j.appender.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%p] %c:%L - %m%n
log4j.appender.com.icesoft.faces.application.D2DViewHandler=FINEST
log4j.appender.com.sun.faces.config.ConfigureListener=FINEST
log4j.appender.org.icepush=FINEST
log4j.appender.org.icepush.application.PushRenderer=FINEST
log4j.appender.org.icepush.application.PortableRenderer=FINEST
log4j.appender.org.icefaces=FINEST
I have added the above code in my log4j.properties file, but it is not working I got from here here it is doing console appender, but I want FileAppender. Without specifying anything how it will decide what to log e.g I have configured other logs and it is logging, in the log4j.properties I have mentioned like
log4j.appender.defalut=org.apache.log4j.RollingFileAppender
log4j.appender.defalut.File=D:/xyz.log
log4j.appender.defalut.MaxFileSize=20MB
log4j.appender.defalut.MaxBackupIndex=5
log4j.appender.defalut.layout=org.apache.log4j.PatternLayout
log4j.appender.defalut.layout.conversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%p] %c:%L - %m%n

Related

Log4j properties for an Webservice/API

In my project there are multiple Rest webservices/APIs where I need to have a separate log file for each webservice with appropriate Input request, processing steps and response. All these webservice will call the same jar.
I have tried the below configurations but the common jar processing logs are getting logged in all the api logs.The root package of the common jar is fr.com.api.common . I have even placed the addivity as false,but it is not working.
log4j.appender.api1Log=org.apache.log4j.RollingFileAppender
log4j.appender.api1Log.File=api1Log.log
log4j.appender.api1Log.Threshold=INFO
log4j.appender.api1Log.Append=true
log4j.appender.api1Log.ImmediateFlush=true
log4j.appender.api1Log.MaxFileSize=50000KB
log4j.appender.api1Log.MaxBackupIndex=10
log4j.appender.api1Log.layout=org.apache.log4j.PatternLayout
log4j.appender.api1Log.layout.ConversionPattern=%d %-5p [%c] (%t) %m%n
log4j.logger.fr.com.api.rest.api1=INFO, api1Log
log4j.additivity.fr.com.api.rest.api1=false
log4j.appender.api2Log=org.apache.log4j.RollingFileAppender
log4j.appender.api2Log.File=api2Log.log
log4j.appender.api2Log.Threshold=INFO
log4j.appender.api2Log.Append=true
log4j.appender.api2Log.ImmediateFlush=true
log4j.appender.api2Log.MaxFileSize=50000KB
log4j.appender.api2Log.MaxBackupIndex=10
log4j.appender.api2Log.layout=org.apache.log4j.PatternLayout
log4j.appender.api2Log.layout.ConversionPattern=%d{yyyy-MM-dd HH\:mm\:ss,SSS} %-5p %l - %m%n
log4j.logger.fr.com.api.rest.api2=INFO, api2Log
log4j.additivity.fr.com.api.rest.api2=false
log4j.logger.fr.com.api.common=INFO,api2Log,api1Log
log4j.additivity.fr.com.api.common=false

Wildfly 8.1 Log System

I am trying to make my Web Services Application Log using Wildfly 8.1 Final Log System Categories.
My App declares
private static final Logger LOGGER = Logger.getLogger("myapp");
It calls in parts of the code for
LOGGER.debug("something");
Using the log4j property file definition below it behaves as expected. The problem is when I access the Wildfly console (http://localhost:9990/console/App.html#logging) and update the Log Category named "myapp" from INFO to DEBUG. After tha I call my Web Service that calls the instruction LOGGER.debug("something"); inside it´s code.
The expected behavior is to show the "something" message written in my log file, but it does not happens because it behaves obeying only the log4j property file supplied below.
How to fix this?
#------------------------------------------------------------------------------
#log4j.rootLogger=DEBUG, stdout
log4j.logger.org.hibernate=INFO, stdout, myapp
log4j.logger.org.hibernate.SQL=INFO, stdout, myapp
log4j.logger.org.hibernate.type.descriptor.sql=ALL, stdout, myapp
log4j.logger.myappaudit=INFO, myappaudit
log4j.logger.myapp=INFO, stdout, myapp
log4j.logger.performance=INFO, myapp
#
# default Appender
#------------------------------------------------------------------------------
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{yyyy-MM-dd HH:mm:ss.SSS} %c{1} [%p] %C{1}.%M - %m%n
#
# Appender for myappaudit
#------------------------------------------------------------------------------
log4j.appender.myappaudit = org.apache.log4j.DailyRollingFileAppender
log4j.appender.myappaudit.File = ${jboss.server.log.dir}/logs/myappaudit.log
log4j.appender.myappaudit.Append = true
log4j.appender.myappaudit.DatePattern = '.'yyy-MM-dd
log4j.appender.myappaudit.layout = org.apache.log4j.PatternLayout
log4j.appender.myappaudit.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss.SSS} %c{1} [%p] %m%n
#
# Appender for application
#------------------------------------------------------------------------------
log4j.appender.myapp = org.apache.log4j.DailyRollingFileAppender
log4j.appender.myapp.File = ${jboss.server.log.dir}/logs/console.log
log4j.appender.myapp.Append = true
log4j.appender.myapp.DatePattern = '.'yyy-MM-dd
log4j.appender.myapp.layout = org.apache.log4j.PatternLayout
log4j.appender.myapp.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss.SSS} %c{1} [%p] %m%n
#Spring logs
log4j.logger.org.springframework=DEBUG
log4j.logger.org.springframework.security=DEBUG
log4j.logger.org.springframework.ws=DEBUG
#Spring Transaction Logs
log4j.logger.org.springframework.orm.jpa=DEBUG
log4j.logger.org.springframework.transaction=DEBUG
#Spring Async Logs
log4j.logger.org.springframework.scheduling=ERROR
You will not be able to use the logger options in the console. The reason is that if you include a log4j config an entirely isolated logging instance is created for that deployment. If you want to use jboss's tools, you must remove your logging config and define in the standalone or domain xml. Alternatively, you can create your own servlet or mbean that is part of your deployment to make runtime adjustments to the logging level or any other changes, e.g adding or removing appenders
So, to be clear, are you packaging a log4j.properties file with your application? It that being respected correctly, but you hoped to use the jboss console to amend the logging level at runtime?

log4j appender with a file url

I have a problem where log4j is not logging to one of my files and i'm not sure why. I have some code that runs scripts, the scripts can add logging which is logged to a file using log4j, I am trying to create an appender that only logs for a particular script.
log4j.logger.com.my.class=INFO, JS_LOG
log4j.appender.JS_LOG.layout=org.apache.log4j.PatternLayout
log4j.appender.JS_LOG.Encoding=UTF-8
log4j.appender.JS_LOG.File=${log.outputdir}/js_service.log
log4j.appender.JS_LOG.MaxFileSize=2MB
log4j.appender.JS_LOG.MaxBackupIndex=10
log4j.appender.JS_LOG.Append=true
log4j.appender.JS_LOG=org.apache.log4j.RollingFileAppender
log4j.appender.JS_LOG.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n
the above appender works and i get this in my log file
2012-04-18 11:25:52,043 [<MD> Inc Msg Dispatch-1 New] INFO com.my.class.file:/myfile - info
when the script logs something it logs to a logger of the form
com.my.class.file:/myfile this appears in the log using the above config in my log4j.properties file.
if I change the above to:
log4j.logger.com.my.class.file:/myfile=INFO, JS_LOG
log4j.appender.JS_LOG.layout=org.apache.log4j.PatternLayout
log4j.appender.JS_LOG.Encoding=UTF-8
log4j.appender.JS_LOG.File=${log.outputdir}/js_service.log
log4j.appender.JS_LOG.MaxFileSize=2MB
log4j.appender.JS_LOG.MaxBackupIndex=10
log4j.appender.JS_LOG.Append=true
log4j.appender.JS_LOG=org.apache.log4j.RollingFileAppender
log4j.appender.JS_LOG.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n
nothing is logged to the file. I would have thought this should work? I retrieve the file
I managed to solve this problem, its something to do with the file: in my log4j.properties I changed the appender to file_ then in my code I do some manipulation to the file url to make it match the appender.

logging configuration with log4j.properties, cannot exclude package from logging to console

i have the following log4j.properties file. what i want to do is log everything at the level INFO or above to the console. however, for anything that falls in the demo.* package, i want to log everything at the DEBUG level to a file. my log4j.properties below does not seem to work. what happens is that any DEBUG message from demo.* still gets output to the console. any idea what i am doing wrong?
how can i exclude demo.* from logging to the console?
log4j.rootLogger=INFO, C
log4j.logger.demo=DEBUG, R1
log4j.appender.C=org.apache.log4j.ConsoleAppender
log4j.appender.C.target=System.err
log4j.appender.C.layout=org.apache.log4j.PatternLayout
log4j.appender.C.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{2}: %m%n
log4j.appender.R1=org.apache.log4j.RollingFileAppender
log4j.appender.R1.File=output.log
log4j.appender.R1.MaxFileSize=5MB
log4j.appender.R1.MaxBackupIndex=5
log4j.appender.R1.layout=org.apache.log4j.PatternLayout
log4j.appender.R1.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{2}: %m%n
sorry, never mind. i solved it by setting the threshold of the console appender.
log4j.appender.C.threshold=INFO

Creating an application specific log under Tomcat 7?

I'm trying to capture logging messages, stdout, and stderr for my webapp, which is running under Tomcat 7.
I have a log4j.properties file in my war file, at WEB-IN/classes/log4j.properties, pretty much copied from the log4j docs, except with a filename "myapp.log":
# Set root logger level to DEBUG and its only appender to A1.
log4j.rootLogger=DEBUG, A1
# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.File=${catalina.home}/logs/myapp.log
# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
WEB-INF/lib includes log4j-1.2.14.jar and commons-logging-1.0.4.
I'm expecting to see myapp.log appear in Tomcat's log directory, but it's not. Please explain to me what I'm doing wrong.
You're using a ConsoleAppender where you should be using a file appender:
log4j.appender.A1=org.apache.log4j.RollingFileAppender

Resources