LeanMoreTryMore
asked on
log4j.xml - can i configure to see the warning message only
I use the following log4j.xml. My question is there is too much infomration shown in the log file.
My question is how can i configure the log4j to just display certain information such warning or info
Thanks in advance
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="myAppender" class="org.apache.log4j.Fi leAppender ">
<param name="File" value="my.log"/>
<layout class="org.apache.log4j.Si mpleLayout "/>
</appender>
<root>
<priority value="debug" />
<appender-ref ref="myAppender"/>
</root>
</log4j:configuration>
My question is how can i configure the log4j to just display certain information such warning or info
Thanks in advance
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="myAppender" class="org.apache.log4j.Fi
<param name="File" value="my.log"/>
<layout class="org.apache.log4j.Si
</appender>
<root>
<priority value="debug" />
<appender-ref ref="myAppender"/>
</root>
</log4j:configuration>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://logging.apache.org/log4j/docs/manual.html
************************** ********** ********** *
package com.ee;
Class MyExample {
static final Logger logger = Logger.getLogger(MyExample .class.get Name());
void someInterestingMethod() {
logger.warn("I am going to do something interesting");
//actually do something interesting
logger.warn("I did somethign really interesting");
}
}
**************************
package com.ee;
Class MyExample {
static final Logger logger = Logger.getLogger(MyExample
void someInterestingMethod() {
logger.warn("I am going to do something interesting");
//actually do something interesting
logger.warn("I did somethign really interesting");
}
}
The above example is a very crude way of saying typically in some method like placingOrder,
Class MyExample {
static final Logger logger = Logger.getLogger(MyExample .class.get Name());
void placeOrder(Customer customer) {
if(customer.isCreditLimitD angerous() ) {
logger.warn("Placing an order for the customer ["+ customer + "] is potentially dangerous.");
}
//place order here
}
}
Class MyExample {
static final Logger logger = Logger.getLogger(MyExample
void placeOrder(Customer customer) {
if(customer.isCreditLimitD
logger.warn("Placing an order for the customer ["+ customer + "] is potentially dangerous.");
}
//place order here
}
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
CEHJ,
the question was:
>My question is how can i configure the log4j to just display certain information such warning or info
and not
>can i configure to see the warning message only
Maybe there is something I ignore, but I do not understand.
:-?
the question was:
>My question is how can i configure the log4j to just display certain information such warning or info
and not
>can i configure to see the warning message only
Maybe there is something I ignore, but I do not understand.
:-?
> Maybe there is something I ignore
Would seem more CEHJ ignoring what was asked :)
Would seem more CEHJ ignoring what was asked :)
>>Maybe there is something I ignore
Yes - the title of the question ;-)
Yes - the title of the question ;-)
ASKER
Thanks for all.
You are all very helpful
You are all very helpful
>> .... have their warning messages in one log.
There's no need to atomise you log file like that. If you want to inspect only warnings, given Windows, you can simply do
type your.log | find "WARN" >temp-warn.log
then delete the file temp-warn.log when you've finished looking
There's no need to atomise you log file like that. If you want to inspect only warnings, given Windows, you can simply do
type your.log | find "WARN" >temp-warn.log
then delete the file temp-warn.log when you've finished looking
ASKER
just want to get some idea. thanks