File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Open Source Projects and the fly likes own log4j appender Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "own log4j appender" Watch "own log4j appender" New topic
Author

own log4j appender

ivan stefko
Greenhorn

Joined: Jan 18, 2010
Posts: 12
hi,
I'm going to use DailyRollingFileAppender but I need some special functionality of it. So, solution is write own appender (extends from DailyRollingFileAppender). DailyRollingFileAppender 'roll' periodicaly log file according datePattern which are defined in log4j.xml file => join timestamp to name of logfile.

I need
1. default log direcotry for log4j will be DIRECTORY1 (somewhere in my HDD) - there will be always 1 file (because rolling file will be moving to other directory)
2. move rolling logfile to specific directory (DIRECTORY2)... => log4j find out that is time to roll log file -> join timestamp to log file name -> move this file to my new directory (DIRECTORY2)

how can i write own appender and which method i have to overwrite?

thank you..
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Have you read the guide on the log4j website?


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
ivan stefko
Greenhorn

Joined: Jan 18, 2010
Posts: 12
Martijn Verburg wrote:Have you read the guide on the log4j website?

yes, i looked there but i didn't find something what is usefull for my case... . some idea? or usefull link?
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Have you tried writing some code to extend the class? Is there something you are stuck on in particular?
ivan stefko
Greenhorn

Joined: Jan 18, 2010
Posts: 12
Martijn Verburg wrote:Have you tried writing some code to extend the class? Is there something you are stuck on in particular?

ironic, ironic..

problem is that DailyRollingFileAppender has method rollOver as private... . you know what means 'private' clausula in base class?? i think so.. .

i need overwride this method - rollOver - because there is joining full path for rolling file.. => but it isn't possible. so i need some solution for it... .

some other constructive suggestions?

Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10202
    
166

ivan stefko wrote:
ironic, ironic..

...
some other constructive suggestions?



So without telling us what exactly you were stuck at and what you have tried so far, you wanted us to guess the issue?

[My Blog] [JavaRanch Journal]
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10202
    
166

ivan stefko wrote:
problem is that DailyRollingFileAppender has method rollOver as private...
i need overwride this method - rollOver - because there is joining full path for rolling file.. => but it isn't possible. so i need some solution for it... .


So that would mean, you will perhaps have to extend from FileAppender instead of DailyRollingFileAppender and then rewrite your own logic.
ivan stefko
Greenhorn

Joined: Jan 18, 2010
Posts: 12
Jaikiran Pai wrote:
ivan stefko wrote:
problem is that DailyRollingFileAppender has method rollOver as private...
i need overwride this method - rollOver - because there is joining full path for rolling file.. => but it isn't possible. so i need some solution for it... .


So that would mean, you will perhaps have to extend from FileAppender instead of DailyRollingFileAppender and then rewrite your own logic.


yes.. it's possible .. good idea. my another idea is a take source code of DailyRollingFileAppender and rewrite by my logic...

thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: own log4j appender