aspose file tools*
The moose likes Other Java Products and Servers and the fly likes Log4j : custom each log file for each client in the network Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Java Products and Servers
Bookmark "Log4j : custom each log file for each client in the network" Watch "Log4j : custom each log file for each client in the network" New topic
Author

Log4j : custom each log file for each client in the network

Manuel Jordan
Ranch Hand

Joined: Sep 29, 2006
Posts: 131
Hello guys

i have this situation, one server Spring/Hibernate etc
and 3 clients by intranet

ok i want to have this behaviour for log4j

global.log logging all events of the application
server.log logging all events if some user use the server how client (test purposes or other reason)
client1.log logging all events done by client1 in its own machine of course
client2.log logging all events done by client2 in its own machine of course
client3.log logging all events done by client3 in its own machine of course

careful that client1 and 3 can access same area of the application

i need have a historial by each client

all the log files must be located in the server, nothing in the client machine

how i can do that???

thanks in advanced


kill your pride, share your knowledge with all
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
How would you differentiate between the requests from various clients?


Rahul Bhattacharjee
LinkedIn - Blog
Manuel Jordan
Ranch Hand

Joined: Sep 29, 2006
Posts: 131
Hello Rahul
thanks for the reply

How would you differentiate between the requests from various clients?

by roles, i work with acegi, so with the context i can get which user call the method or class, i can use AOP if is necessary

regards
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Once I had to do a similar thing where I was needed to store logs of each request in seperate file.What I did was I created loggers programatically and created appenders programatically .Then added the appender in the logger and then used it.
Hope this helps,
Manuel Jordan
Ranch Hand

Joined: Sep 29, 2006
Posts: 131
Hello Rahul

What I did was I created loggers programatically and created appenders programatically .Then added the appender in the logger and then used it.

you did the code from the scratch or you read some tutorial
if is a tutorial pls share the link

if not, can you share your code??

thanks for advanced
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
I do not have the code with me right now.But you can yourself figure this out from the javadoc of log4j api.

Create an Appender instance and set all the required properties for that appender and set it to the right logger.That is all you need to do.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Log4j : custom each log file for each client in the network