• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

own log4j appender

 
ivan stefko
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you read the guide on the log4j website?
 
ivan stefko
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried writing some code to extend the class? Is there something you are stuck on in particular?
 
ivan stefko
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic