File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Logging a single java application into 2 logs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Logging a single java application into 2 logs" Watch "Logging a single java application into 2 logs" New topic
Author

Logging a single java application into 2 logs

cle tan
Ranch Hand

Joined: Jun 11, 2012
Posts: 68
Let's say my application have 2 outcomes, success and failure

If success, it will log into one log, if fail it will log into another

but somehow, when it logs, logging messages will show in both of the logs

The code is shown below:
William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 860

Are you using log4j as the underlying framework?

If so, check the addidivity clause, e.g:


WP
cle tan
Ranch Hand

Joined: Jun 11, 2012
Posts: 68
William P O'Sullivan wrote:Are you using log4j as the underlying framework?

If so, check the addidivity clause, e.g:


WP


no i am using java.util.logging framework

i have probs configuring with the log4j, first is the log4j.properties, i find it a bit troublesome and confusing

is it possible to implement it with java.util.logging framework?
William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 860

Can you post your properties file then?

WP
cle tan
Ranch Hand

Joined: Jun 11, 2012
Posts: 68
William P O'Sullivan wrote:Can you post your properties file then?

WP

not very sure whether my installation was correct for log4j

i just put the log4j.jar inside the java ext lib for jdk and jre

then now there seems to be a log4j alpha ver, without a jar

not sure what's it used for


cle tan
Ranch Hand

Joined: Jun 11, 2012
Posts: 68
William P O'Sullivan wrote:Can you post your properties file then?

WP


this is my log4j.properties file

not very sure where should i place in eclipse , and where is my output for the logger
cle tan
Ranch Hand

Joined: Jun 11, 2012
Posts: 68
anyone knows how to solve this problem?

i need more guidance regarding this

i have been going through log4j documentation but can't get it to work as it can't locate the log4j.properties file
William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 860

You said you were not using log4j due to problems you had!

I think you're confused. Logging frameworks such as commons and slf4j can be complex but usually
sit on top of a physical logging layer (They are facades). I would write a very simple servlet and test
the logging that your code uses.

Also, what is your application server?

WP
Bill Clar
Ranch Hand

Joined: Sep 21, 2006
Posts: 140



What's happening here? Should errorLogger and auditLogger be distinct, separate logs?

cle tan
Ranch Hand

Joined: Jun 11, 2012
Posts: 68
William P O'Sullivan wrote:You said you were not using log4j due to problems you had!

I think you're confused. Logging frameworks such as commons and slf4j can be complex but usually
sit on top of a physical logging layer (They are facades). I would write a very simple servlet and test
the logging that your code uses.

Also, what is your application server?

WP


I am still welcoming any solution that can solve my problem, be it java .util.logging or log4j.

I am using the log4j as i assume there is no easy solution if i use java.util.logging


I am just running a eclipse java application but am having problems with log4j logger

Somehow I put the log4j.properties in the src file and it works, but i can't output the file
src
|---package
|----log4j.properties


may i know whether I can write this code in log4j.properties?
log4j.appender.FILE=org.apache.log4j.FileAppender
log4j.appender.FILE.File=C:/logging.log
cle tan
Ranch Hand

Joined: Jun 11, 2012
Posts: 68
Bill Clar wrote:

What's happening here? Should errorLogger and auditLogger be distinct, separate logs?



yes, how do i configure them to be distinct and separate logs to log the same java application?

Note that the code above uses java.util.logging
cle tan
Ranch Hand

Joined: Jun 11, 2012
Posts: 68
implemented separate logging in 2 classes

so that if success logging will be done in another class

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Logging a single java application into 2 logs
 
Similar Threads
logging and documentation
Help needed on File logging
Writing logs to a single file from Multiple Classes
How to make each log entry start on a new line?