Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Manuel Jordan
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How would you differentiate between the requests from various clients?
 
Manuel Jordan
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic