Disable jboss server log files - java

I have using simple web application which is hosted in Linux VM on jboss-eap-6.2. Application works fine.
Since My VM is containing very small amount of space I was trying reduce unnecessary log files. For me info log is very much sufficient and
You see there will be always server logs will be inherited automatically when server starts up. Here as follow in server path :
opt/gnrtestbed/jboss-eap-6.4/standalone/log>
-rw-r--r-- 1 gnrtb gnrtestbed 1864 Mar 7 07:40 gc.log.0.current
-rw-r--r-- 1 gnrtb gnrtestbed 14770464 Mar 7 07:40 server.log
so on so
And I don’t want any log details like console, boot,...etc.
I want to control the jboss log server in manner that I can only produce the log which I want.. For me just info which logged/coded in application is more than enough since its very small application
I have searched long in online and many suggested to disable the logs like below through add these lines to standalone.xml or domain.xml:
<system-properties>
<property name="org.jboss.as.logging.per-deployment" value="false"/>
</system-properties>
This above is also not helping. After adding this lines unable to start the server and end up in errors
so on so
And also, I have tried all the commenting stuffs inside of logging.properties file under path :
/opt/gnrtestbed/jboss-eap-6.4/standalone/configuration>
But I couldn’t stop the console,.. server logs… its just keep pouring...
Please let me know what I am missing or what I have to do further to avoid default server logs. Your help will be appreciated. Thanks
For your detailed understanding let me share my logging properties file as follow :
# Note this file has been generated and will be overwritten if a
# logging subsystem has been defined in the XML configuration.
# Additional loggers to configure (the root logger is always configured)
loggers=sun.rmi,jacorb,org.jboss.as.config,jacorb.config,org.apache.tomcat.util.modeler,com.arjuna,System.out
logger.level=TRACE
logger.handlers=FILE,CONSOLE
logger.sun.rmi.level=WARN
logger.sun.rmi.useParentHandlers=true
logger.jacorb.level=WARN
logger.jacorb.useParentHandlers=true
logger.org.jboss.as.config.level=DEBUG
logger.org.jboss.as.config.useParentHandlers=true
logger.jacorb.config.level=ERROR
logger.jacorb.config.useParentHandlers=true
logger.org.apache.tomcat.util.modeler.level=WARN
logger.org.apache.tomcat.util.modeler.useParentHandlers=true
logger.com.arjuna.level=WARN
logger.com.arjuna.useParentHandlers=true
logger.System.out.level=WARN
logger.System.out.useParentHandlers=true
handler.CONSOLE=org.jboss.logmanager.handlers.ConsoleHandler
handler.CONSOLE.level=WARN
handler.CONSOLE.formatter=CONSOLE
handler.CONSOLE.properties=enabled,autoFlush,target
handler.CONSOLE.enabled=true
handler.CONSOLE.autoFlush=true
handler.CONSOLE.target=SYSTEM_OUT
handler.FILE=org.jboss.logmanager.handlers.PeriodicRotatingFileHandler
handler.FILE.level=ALL
handler.FILE.formatter=FILE
handler.FILE.properties=append,autoFlush,enabled,suffix,fileName
handler.FILE.append=true
handler.FILE.autoFlush=true
handler.FILE.enabled=true
handler.FILE.suffix=.yyyy-MM-dd
handler.FILE.fileName=/opt/gnrtestbed/jboss-eap-6.4/standalone/log/server.log
formatter.CONSOLE=org.jboss.logmanager.formatters.PatternFormatter
formatter.CONSOLE.properties=pattern
formatter.CONSOLE.constructorProperties=pattern
formatter.CONSOLE.pattern=%K{level}%d{HH\:mm\:ss,SSS} %-5p [%c] (%t) %s%E%n
formatter.FILE=org.jboss.logmanager.formatters.PatternFormatter
formatter.FILE.properties=pattern
formatter.FILE.constructorProperties=pattern
formatter.FILE.pattern=%d{HH\:mm\:ss,SSS} %-5p [%c] (%t) %s%E%n

Related

Log4j not writing logs to file on one Websphere server and writing to file on other

I have maven application with log4j.properties in it with setting to write the logs to a specified file instead of console. When I run the EAR on one of the websphere servers it is creating the file as expected and writing logs to it. But, when I am running the same EAR on other webspehere server it is writing to console instead of writing the logs to the specified file. I have checked the permissions and everything seems to be fine. Please help me in identifying what the issue is. Thanks in advance.
# CONSOLE APPENDER (stdout)
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Threshold=DEBUG
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%d] [%t] %-5p %20c - %m%n
# ROLLING FILE APPENDER (on the file system) for memberpolicyattributesservice code
log4j.appender.xxxxService=org.apache.log4j.RollingFileAppender
log4j.appender.xxxxService.Threshold=DEBUG
log4j.appender.xxxxService.File=/var/logs/xxxServer1/xxxServiceLog.log
log4j.appender.xxxxService.layout=org.apache.log4j.PatternLayout
log4j.appender.xxxxService.layout.ConversionPattern=%d{MM-dd#HH:mm:ss} %-5p (%13F:%L) %3x - %m%n
log4j.appender.xxxxService.MaxFileSize=10000KB
log4j.appender.xxxxService.MaxBackupIndex=30
log4j.appender.xxxxService.layout=org.apache.log4j.PatternLayout
log4j.appender.xxxxService.layout.ConversionPattern=[%d] [%t] %-5p %20c - %m%n
# ROLLING FILE APPENDER (on the file system) for hiberate, open source code log files
log4j.appender.open_source_code=org.apache.log4j.RollingFileAppender
log4j.appender.open_source_code.layout=org.apache.log4j.PatternLayout
log4j.appender.open_source_code.Threshold=DEBUG
#message format:YYYY-MM-DD HH:mm:ss,ms [ThreadId] <PRIORITY> classname.message
log4j.appender.open_source_code.layout.ConversionPattern=%d [%t]<%-5p> %c.%m \r\n
#file that will be logged to
log4j.appender.open_source_code.File=/var/logs/xxxServer1/open_source_code.log
log4j.appender.open_source_code.Append=true
log4j.appender.open_source_code.MaxFileSize=1024KB
log4j.appender.open_source_code.MaxBackupIndex=5
#turn on log4j verbose mode
log4j.debug = true
# Set root logger level to INFO and its appender to DSInstrumentor,stdout.
log4j.rootLogger=DEBUG,stdout,xxxxService
# YOUR CATEGORIES (to customize logging per class/pkg/project/etc)
log4j.category.fatal=FATAL,xxxxService
log4j.category.error=ERROR,xxxxService
#This will also enable the logging for all the children (packages and classes) of this package
log4j.logger.com.xxxxx=ALL,xxxxService
# Print only messages of level INFO in the open source code
log4j.logger.org=INFO,open_source_code
You have multiple loggers defined in your root logger (DEBUG, stdout, xxxxService) but the xxxxService loggers look like they're bound to the file system on one of the systems:
log4j.appender.open_source_code.File=/var/logs/xxxServer1/open_source_code.log
Make sure that path is valid for each server in your WAS cluster.
As a side note, you should probably avoid using debug and stdout on a remote server. This is fine for local development in your workstation, but not on a remote box. Instead, provide different log4j properties on your various deployment tiers. This lets you customize the log location or appender (say c:\temp or CONSOLE on your desktop, but /var/logs ... on all remote machines) as well as your log levels (DEBUG for desktop, maybe INFO for QA or Staging, and WARN or ERROR for Production).

Webapp logging settings are being ignored

I'm not able to get output with priority lower than INFO from a webapp. Everything other is being logged correctly.
Log shows the following, yet actual settings put in to the file are seem to be ignored:
INFO: Initializing log4j from
[/var/lib/tomcat-7-main/webapps/myapp/WEB-INF/log4j.properties]
Content of the file is following:
log4j.rootLogger=TRACE, console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.conversionPattern=%5p [%t] (%F:%L) - %m%n
log4j.logger.my.webapp=TRACE
log4j.logger.org.springframework.security=TRACE
This configuration works correctly with another machine running openSUSE (while the issue is related to machine running Gentoo). Both of them running Tomcat 7 under Oracle JDK 1.7. Any ideas?

log4j: logging works when package inside app, but not when package contributed by a JAR

This isn't just a rehash of how to do package-specific logging. I think I've got that nailed. It's about logging not being done when the package is moved out to a JAR shared with others.
Originally, I wrote some special logging into my web application which worked, putting special statements into a file separate from catalina.out. Later, it seemed useful to share this facility with other, cooperating web applications, so we moved the package, consisting of one interface and one class, to a utilities JAR. While the information-gathering continued successfully, the output to the "special" log file, separate from catalina.out, ceased.
When I relocate a copy of the package back into my application, the logging begins working again as originally designed.
The package name remains the same no matter whether it's physically part of my application code or linked in from a consumed library JAR.
I'm struggling to understand a class linked from a JAR is seemingly excluded from the logging scheme while it works flawlessly when simply part of the application code.
Thank you for taking the time to look at this. Any suggestions would be greatly appreciated.
Here's log4j.properties:
# --------------------------------------------------------------------------------------------
# 1) Standard Tomcat log (tomcat): /var/log/tomcat6/catalina.out
# 2) Splunkable output log (splunkable): /var/log/tomcat6/myapp.log.
# 3) Console used when debugging myapp from Eclipse.
log4j.rootLogger=TRACE,tomcat,console
# Rolling-file appender for Tomcat -----------------------------------------------------------
log4j.appender.tomcat.Threshold=INFO
log4j.appender.tomcat=org.apache.log4j.DailyRollingFileAppender
log4j.appender.tomcat.DatePattern='.'yyy-MM-dd
log4j.appender.tomcat.File=${catalina.home}/logs/catalina.out
log4j.appender.tomcat.file.MaxFileSize=500Mb
log4j.appender.tomcat.file.MaxBackupIndex=5
log4j.appender.tomcat.layout=org.apache.log4j.PatternLayout
log4j.appender.tomcat.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
# Splunkable log -----------------------------------------------------------------------------
log4j.appender.splunkable.Threshold=TRACE
log4j.appender.splunkable=org.apache.log4j.RollingFileAppender
log4j.appender.splunkable.File=${catalina.home}/logs/myapp.log
log4j.appender.splunkable.MaxFileSize=1Gb
log4j.appender.splunkable.MaxBackupIndex=7
log4j.appender.splunkable.layout=org.apache.log4j.PatternLayout
log4j.appender.splunkable.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}: %m%n
# Set the additivity flag to false to avoid propagating the rather verbose splunkable
# output to the normal Tomcat and console logs. Is this mere superstition?
log4j.category.com.acme.web.myapp.logging=TRACE,splunkable
log4j.additivity.com.acme.web.myapp.logging=false
# This logs output to the Eclipse console when running in that mode --------------------------
log4j.appender.console.Threshold=TRACE
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.SimpleLayout
log4j.appender.console.Target=System.out
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

log4j: How to use SocketAppender?

I've got an answer about how to use SocketAppender (I need it to gather logs from distributed system), but I am new to log4j and I have no idea how to use that sample code.
Probably I should have log4j-server.properties like that:
log4j.appender.SERVER=org.apache.log4j.net.SocketAppender
log4j.appender.SA.Port=4712
log4j.appender.SA.RemoteHost=loghost
log4j.appender.SA.ReconnectionDelay=10000
But I still don't know how to start the server (how to use this line)
org.apache.log4j.net.SimpleSocketServer 4712 log4j-server.properties
And what is the most important:
Where\How can I see my logs?
You can run the server using
java -classpath log4j.jar org.apache.log4j.net.SimpleSocketServer 4712 log4j-server.properties
The SimpleSocketServer receives logging events sent to the specified port number by the remote SocketAppender, and logs them as if they were generated locally, according to the configuration you supply in log4j-server.properties. It's up to you to configure the relevant console/file/rolling file appenders and attach them to the relevant loggers just as you would if you were doing the logging directly in the original process rather than piping the log events over a network socket. I.e. if you're currently creating local log files with something like:
log4j.rootLogger=DEBUG, file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=logfile.log
log4j.appender.file.MaxFileSize=1MB
log4j.appender.file.MaxBackupIndex=1
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=[%d] [%t] [%m]%n
then you would change it so that the sending side log4j.properties simply says
log4j.rootLogger=DEBUG, server
log4j.appender.server=org.apache.log4j.net.SocketAppender
log4j.appender.server.Port=4712
log4j.appender.server.RemoteHost=loghost
log4j.appender.server.ReconnectionDelay=10000
and the server-side log4j-server.properties contains the definitions that were previously on the sending side:
log4j.rootLogger=DEBUG, file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=logfile.log
log4j.appender.file.MaxFileSize=1MB
log4j.appender.file.MaxBackupIndex=1
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=[%d] [%t] [%m]%n
In particular, note that there's no point specifying a layout on the SocketAppender on the sending side - what goes over the network is the whole logging event object, it's the receiving side that is responsible for doing the layout.
To start the server simple type below command in command prompt and server will be up and running:
java -classpath C:Users.m2repositorylog4jlog4j1.2.17log4j-1.2.17.jar org.apache.log4j.net.SimpleSocketServer 4712 log4j-server.properties
Please do not forget to specify the correct path of log4j.jar in your system.

Tomcat 6 Log4j Configuration - stdout still being written to?

I have followed the directions to configure tomcat 6 to log using log4j from here: Logging in Tomcat
However, I have noticed that threads appear to be logging to stdout, with no regard to the log level set in log4j.properties. Here is my log4j.properties file:
log4j.rootLogger=WARN, CATALINA
# Define all the appenders
log4j.appender.CATALINA=org.apache.log4j.DailyRollingFileAppender
log4j.appender.CATALINA.file=${catalina.base}/logs/tomcat.out
log4j.appender.CATALINA.encoding=UTF-8
# Roll-over the log once per day
log4j.appender.CATALINA.DatePattern='.'yyyy-MM-dd'.log'
log4j.appender.CATALINA.layout.ConversionPattern = %d [%t] %-5p %c- %m%n
log4j.appender.CATALINA.layout=org.apache.log4j.PatternLayout
log4j.appender.CATALINA.append=true
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.encoding=UTF-8
log4j.appender.CONSOLE.conversionPattern = %d [%t] %-5p %c- %m%n
# Configure which loggers log to which appenders
#log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost]=INFO, LOCALHOST
#log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager]=INFO, MANAGER
#log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager]=INFO, HOST-MANAGER
log4j.logger.org.hibernate.hql.ast=ERROR
This is the file that's in my ${CATALINA_BASE}/lib directory. Notice the last line where I set org.hibernate.hql.ast level to ERROR. The following is constantly being spewed into my tomcat.out log:
15663118 [http-8080-1] WARN org.hibernate.hql.ast.QueryTranslatorImpl - firstResult/maxResults specified with collection fetch; applying in memory!
15663531 [TP-Processor7] WARN org.hibernate.hql.ast.QueryTranslatorImpl - firstResult/maxResults specified with collection fetch; applying in memor
62100 [http-8080-18] INFO org.hibernate.cache.StandardQueryCache - starting query cache at region: video
I have a similar log4j.properties file deployed in my webapp under WEB-INF/classes that have similar properties (but logs to a different file). How come the log statements do not follow the conversion pattern I have defined, nor follow the log level limit I set?
I'm running tomcat 6.0.30, Java 1.6.0_23, and log4j 1.2.16 on SunOS 5.10 amd64. The output to my application log works as expected. Thanks in advance for your help.
Andrew
The main problem here is that you're using the old properties file -style way of configuring Log4J. Because most people use XML configuration method these days, you'll be hard pressed to find anyone who can answer the question.
However, what you need to do is to set threshold for each appender. This is how it's done in XML:
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
...
<param name="Target" value="System.out"/>
<param name="Threshold" value="WARN"/>
...
</appender>
It might look like his on flat file:
log4j.appender.Console.Threshold=WARN

Categories