aspose file tools
The moose likes Web Services and the fly likes How can we pass a parameter to log4j..? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Web Services
Reply Bookmark "How can we pass a parameter to log4j..? " Watch "How can we pass a parameter to log4j..? " New topic
Author

How can we pass a parameter to log4j..?

SirishKumar Nukkala
Greenhorn

Joined: Apr 05, 2007
Posts: 6
Hai guys..

Comming to the point.I've got a major problem in log4j i.e to send a parameter to log4j so that it could generate random files( Using file appender ).

My problem is : -

I've got a user of id 47.He sends a file "Blah.xls".The file tracking Id for that ("Blah.xls") file is "EFG123".So, inorder to track the file status i need to log a log file using log4j ("I'm thinking like to create a new log file using file appender") like user-id_file-Tracking-ID.log.

Similarly for another user of id 48 I need to create a different log with his user-id and file-Tracking-ID("randomly generated - don't bother").

So,can i pass any parameter to log4j.xml and create logs dynamically instead of using java code.

I'm pasting the java as well as log4j.xml.

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">

<appender name="ConsoleAppender" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy.MM.dd HH:mm:ss.SSS} %m%n "/>
</layout>
</appender>

<appender name="fileAppender1" class="org.apache.log4j.FileAppender">
<param name="File" value="${i}\info.log" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%r %m%n "/>
</layout>
</appender>

<root>
<priority value ="debug" />
<appender-ref ref="ConsoleAppender"/>
</root>

</log4j:configuration>

Can i pass parameter in ${i} through java.

Can any one please find the solution for my problem.

Your helpness will be appreciated
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35443
    
    9
Welcome to JavaRanch.

Please do not post the same question to multiple forums, and take care to post in a forum that's relevant to the question (log4j ha snothing to do with Web services): CarefullyChooseOneForum

Let's continue the discussion in this duplicate thread, where you have an answer already.


Android appsImageJ pluginsJava web charts
SirishKumar Nukkala
Greenhorn

Joined: Apr 05, 2007
Posts: 6
Oops..!

I'm sorry.I don't know these things.

Thanks for u'r advice Satou kurinosuke
SirishKumar Nukkala
Greenhorn

Joined: Apr 05, 2007
Posts: 6
Sorry once again Ulf Dittmer.

Misspelled u'r name ..


Bye..!
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How can we pass a parameter to log4j..?
 
Similar Threads
RollingFileAppender not happening
How can we pass a parameter to log4j..?
Log4j : specific class to log on FileAppender other classes log on Console Appender.
struts 2 and log4j
Where are my log4j logs getting written to?