how to stop quartz warn loggers - java

Console is getting filled with Quartz WARN loggers all the time and it's really annoying to developers who work in the project to find other logger messages in console.
[2013-09-14 11:18:35,142] WARN {org.quartz.simpl.PropertySettingJobFactory} - No setter on Job class lk.gov.elg.admin.action.detain.DetainJob for property 'system-id'
[2013-09-14 11:18:35,142] WARN {org.quartz.simpl.PropertySettingJobFactory} - No setter on Job class lk.gov.elg.admin.action.detain.DetainJob for property 'end-at'
[2013-09-14 11:18:35,143] WARN {org.quartz.simpl.PropertySettingJobFactory} - No setter on Job class lk.gov.elg.admin.action.detain.DetainJob for property 'cron-expression'
[2013-09-14 11:18:35,144] WARN {org.quartz.simpl.PropertySettingJobFactory} - No setter on Job class lk.gov.elg.admin.action.detain.DetainJob for property 'start-at'
[2013-09-14 11:18:35,144] WARN {org.quartz.simpl.PropertySettingJobFactory} - No setter on Job class lk.gov.elg.admin.action.detain.DetainJob for property 'scheduled-job-id'
[2013-09-14 11:18:35,144] WARN {org.quartz.simpl.PropertySettingJobFactory} - No setter on Job class lk.gov.elg.admin.action.detain.DetainJob for property 'size'
[2013-09-14 11:18:40,086] WARN {org.quartz.simpl.PropertySettingJobFactory} - No setter on Job class lk.gov.elg.admin.action.detain.DetainJob for property 'GNS'
[2013-09-14 11:18:40,087] WARN {org.quartz.simpl.PropertySettingJobFactory} - No setter on Job class lk.gov.elg.admin.action.detain.DetainJob for property 'limit'
[2013-09-14 11:18:40,087] WARN {org.quartz.simpl.PropertySettingJobFactory} - No setter on Job class lk.gov.elg.admin.action.detain.DetainJob for property 'tenantId'
I Google and find a way to do but it didn't give the solution.
<logger name="org.quartz">
<level value="info" />
</logger>
We are using log4j.xml instead of log4j.properties.
Here is the snapshot of log4j.xml file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration debug="true" xmlns:log4j="http://jakarta.apache.org/log4j/">
<!--
Read http://logging.apache.org/log4j/docs/api/org/apache/log4j/DailyRollingFileAppender.html
for more information on DaliyRollingFileAppender configuration options.
-->
<appender name="error" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="/elg/logs/scandium-error.log"/>
<param name="Threshold" value="error"/>
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{DATE} %-5p - [%t] [%x] %m%n"/>
</layout>
</appender>
<appender name="debug" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="/elg/logs/scandium-debug.log"/>
<param name="Threshold" value="trace"/>
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{DATE} %-5p [%t] - %c{1} [%x] - %m%n"/>
</layout>
</appender>
<appender name="info" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="/elg/logs/scandium-info.log"/>
<param name="Threshold" value="info"/>
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{DATE} %-5p %c{1} - [%t] [%x] %m%n"/>
</layout>
</appender>
<appender name="trace" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="/elg/logs/scandium-trace.log"/>
<param name="Threshold" value="info"/>
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{DATE} %-5p %c{1} - [%t] [%x] %m%n"/>
</layout>
</appender>
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<param name="Threshold" value="info"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p %c{1} - [%t] [%x] %m%n"/>
</layout>
</appender>
<category name="com.opensymphony.xwork2.ognl.OgnlValueStack">
<priority value="error"/>
<appender-ref ref="error"/>
<appender-ref ref="console"/>
</category>
<root>
<priority value="trace"/>
<appender-ref ref="info"/>
<appender-ref ref="trace"/>
<appender-ref ref="debug"/>
<appender-ref ref="error"/>
<appender-ref ref="console"/>
</root>
<logger name="org.quartz">
<level value="info" />
</logger>
</log4j:configuration>
Please help to sort out the issue. Thanks in advance.

WARN is a more severe log level than INFO, and so setting your log level to INFO will still get warnings. The best solution is to figure out why you're getting all those warnings; they're pointing to something Quartz thinks is a real problem (you apparently have a bunch of properties set in a configuration somewhere that the target job type doesn't understand). If you absolutely can't fix the real problem, then you can set the log level to ERROR.

Related

Log4j logging two times in logging file

Here is my log4j.xml
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="mylog" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="myLogfile.log" />
<param name="DatePattern" value="'.'yyyy-MM-dd" />
<param name="append" value="true"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n"/>
</layout>
</appender>
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n" />
</layout>
</appender>
<logger name="com.mypackage1">
<level value="DEBUG" />
<appender-ref ref="mylog" />
<appender-ref ref="console" />
</logger>
<root>
<level value="DEBUG" />
<appender-ref ref="console" />
</root>
</log4j:configuration>
in myLogfile.log file i am getting the logging from "com.mypackage1" two times.
Please help put with the issue
If you are redirecting your console output to the same log file from shell, like you mentioned in the comment, then yes, your log file will have duplicate entries. One solution would be to use below log4j config in your program and redirect the console output to a different file - e.g. console.out, that will have your logs and std out separate. If you must have std out in the same file, then redirect std out to the same file.
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="mylog" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="myLogfile.log" />
<param name="DatePattern" value="'.'yyyy-MM-dd" />
<param name="append" value="true"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n"/>
</layout>
</appender>
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n" />
</layout>
</appender>
<logger name="com.mypackage1">
<level value="DEBUG" />
<appender-ref ref="mylog" />
<!-- <appender-ref ref="console" /> -->
</logger>
<root>
<level value="DEBUG" />
<!-- <appender-ref ref="console" /> -->
<appender-ref ref="myLog" />
</root>
</log4j:configuration>

How to separate records in log file by blank line? Log4j

I try to make my log file more readable so I want to separate records in my log file by a blank line after every application run. I use log4j.
I understand that the easiest way is to append %m%n to a single record in code. But I'm interested in doing it via configuration file.
So the question is what I have to add to configuration file log4j.xml?
Here is the context of my log4j.xml configuration file:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration debug="true"
>
<appender name="file" class="org.apache.log4j.RollingFileAppender">
<param name="append" value="true"/>
<param name="maxFileSize" value="10MB"/>
<param name="maxBackupIndex" value="10"/>
<param name="file" value="logs/logs.log"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n"/>
</layout>
</appender>
<root>
<level value="DEBUG"/>
<appender-ref ref="file"/>
</root>
</log4j:configuration>
You could use another Logger defined in your configuration that uses the same settings except its ConversionPattern which will contain only %n. Here is an example:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration debug="true">
<appender name="file" class="org.apache.log4j.RollingFileAppender">
<param name="append" value="true"/>
<param name="maxFileSize" value="10MB"/>
<param name="maxBackupIndex" value="10"/>
<param name="file" value="logs/logs.log"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n"/>
</layout>
</appender>
<appender name="file2" class="org.apache.log4j.RollingFileAppender">
<param name="append" value="true"/>
<param name="maxFileSize" value="10MB"/>
<param name="maxBackupIndex" value="10"/>
<param name="file" value="logs/logs.log"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%n"/>
</layout>
</appender>
<logger name="com.company.MyClass">
<level value="DEBUG"/>
<appender-ref ref="file2"/>
</logger>
<root>
<level value="DEBUG"/>
<appender-ref ref="file"/>
</root>
</log4j:configuration>
Then, when your app starts:
Logger logger = Logger.getLogger(com.company.MyClass.class);
logger.info(" ");
I'm not sure to understand what you want to achieve and why, but if you want an empty line between each log entry, you just have to add an extra %n at the end of your ConversionPattern:
<param name="ConversionPattern"
value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n%n"/>
(%n means "new line")

Spring jdbcTemplate debug messages not getting printed using log4j

I have the below log4j.xml in placed in the src directory of a web application. Even after follwing many post examples, i cannot get the below configuration print jdbcTemplate internals to log file.
Config:
<appender name="INTERNALSLOG" class="org.apache.log4j.RollingFileAppender">
<param name="File" value="C:/springDB.log"/>
<param name="Append" value="true"/>
<param name="MaxFileSize" value="10mb"/>
<param name="MaxBackupIndex" value="5"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%t] %C{2} - %m%n"/>
</layout>
</appender>
<logger name="org.springframework.jdbc.core">
<level value="DEBUG" />
<appender-ref ref="INTERNALSLOG"/>
</logger>
Whats wrong with the configuration. Just want to get the sql's from jdbcTemplate printed.

Log4j how to log by level and the log file should contains only its level's log [duplicate]

I am using log4j for logging in my applicaion. I am trying to different level logs in different files but something going wrong. Any help regrading this issue will be highly appreciated.
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p %c{1} - %m%n"/>
</layout>
</appender>
<appender name="DEBUG" class="org.apache.log4j.RollingFileAppender">
<param name="File" value="TCS_patch_9/log/retailer_debug.log" />
<param name="Threshold" value="DEBUG" />
<param name="MaxFileSize" value="2MB"/>
<param name="MaxBackupIndex" value="3"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ISO8601} %-5p %c - %m%n"/>
</layout>
</appender>
<appender name="INFO" class="org.apache.log4j.RollingFileAppender">
<param name="File" value="TCS_patch_9/log/retailer_info.log" />
<param name="Threshold" value="INFO" />
<param name="MaxFileSize" value="2MB"/>
<param name="MaxBackupIndex" value="3"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ISO8601} %-5p %c - %m%n"/>
</layout>
</appender>
<appender name="ERROR" class="org.apache.log4j.RollingFileAppender">
<param name="File" value="TCS_patch_9/log/retailer_error.log" />
<param name="Threshold" value="ERROR" />
<param name="MaxFileSize" value="2MB"/>
<param name="MaxBackupIndex" value="3"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ISO8601} %-5p %c - %m%n"/>
</layout>
</appender>
<appender name="FATAL" class="org.apache.log4j.RollingFileAppender">
<param name="File" value="TCS_patch_9/log/retailer_repeat_delay.log" />
<param name="Threshold" value="FATAL" />
<param name="MaxFileSize" value="2MB"/>
<param name="MaxBackupIndex" value="3"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ISO8601} %-5p %c - %m%n"/>
</layout>
</appender>
<root>
<priority value ="error" />
<appender-ref ref="console"/>
<appender-ref ref="DEBUG"/>
<appender-ref ref="INFO"/>
<appender-ref ref="ERROR"/>
<appender-ref ref="FATAL"/>
</root>
</log4j:configuration>
The standard behaviour for log4j appenders is that they log all messages at their threshold level or higher, i.e. an appender with threshold INFO will log INFO, WARN, ERROR and FATAL messages but not DEBUG. If you want to log only INFO messages but not WARN and above then you need to use a LevelMatchFilter.
You will also need to set your root logger priority to DEBUG, otherwise it will only send ERROR and FATAL messages to its appenders and your DEBUG and INFO files will be empty.

log4j prints debug to file, but not info

I am able to print debug logs to a file, but I am unable to print info. However, printing info and debug to console works correctly. How do I go about getting info to print in a file as well?
Thanks
<!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= "%-5p [%t]: %m%n"/>
</layout>
</appender>
<appender name="R" class="org.apache.log4j.RollingFileAppender">
<param name="file" value="example.log"/>
<param name="MaxFileSize" value="1000000KB"/>
<param name="MaxBackupIndex" value="1"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value= "%-5p [%t]: %m%n"/>
</layout>
</appender>
<root>
<priority value="info" />
<appender-ref ref="stdout" />
<appender-ref ref="R" />
</root>
</log4j:configuration>
So I was using the java logger object rather than the apache4j logger object...

Categories

Resources