开发者

creating log4j log file name at run time

I am working on an module for import process which can be triggered by various way by user click by schdular etc. and it will go with the phasse of validation and if validation is success than final import. in order to show up validation error to the user we want to use the log file so that if validation failed we will just pick the log file and show that in a window. So far everything was fine but now i need to create a logfile for each import job something like when a job start get timestamp and name the log file based on the time stamp also same time for each job i need to store the log file name for that job so that later can pick the same log file for display purpose.

i gone through various questions on SO Link to similar question but seems tha开发者_运维技巧t the requirement was quite different. One approach which i came to know is to get list of all appenders and den override the name of the file in the code but since we are in web-application i am not sure about the thread safty and any other potential issue

Can some one suggest me how i can create a seperate log file for each import process instance.

Thanks in advance


One can achieve the desired thing by some code like

SimpleLayout layout = new SimpleLayout();   
FileAppender appender = new FileAppender(layout,"your filename",false);   
logger.addAppender(appender);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜