• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

own log4j appender

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..
 
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?

 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
You ridiculous clown, did you think you could get away with it? This is my favorite tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic