I've got this far:
private void backupLogFile() {
ch.qos.logback.classic.Logger log =
(ch.qos.logback.classic.Logger)LoggerFactory.getLogger(LOG.ROOT_LOGGER_NAME);
Iterator<Appender<ILoggingEvent>> itr = log.iteratorForAppenders();
List<Appender<ILoggingEvent>> appenders = new
LinkedList<Appender<ILoggingEvent>>();
while (itr.hasNext()) {
appenders.add(itr.next());
}
for(int i=0;i<appenders.size();++i){
if(appenders.get(i).getName().equals("async-file-appender"))
{
LOG.info("FOUND FILE APPENDER");
FileAppender myFile = (FileAppender)appenders.get(i);
String filename = myFile.getFile();
}
}
}
At runtime, Java tells me
Exception in thread "main" java.lang.ClassCastException:
ch.qos.logback.classic.AsyncAppender incompatible with
ch.qos.logback.core.FileAppender
I can't work out how to get the configured currentLogFilename, anybody know
how do this?
Thanks
On Tuesday, 14 February 2017 18:44:20 UTC, Evan Meagher wrote:
>
> +dropwizard-user, dropwizard-dev to bcc
>
> On Tue, Feb 14, 2017 at 6:00 AM, HAL2000 <[email protected]
> <javascript:>> wrote:
>
>> Hi,
>>
>> I need to rotate or backup the current log file on startup but can't work
>> out how to do it.
>>
>> I have a typical log config:
>>
>> appenders:
>> - type: console
>> threshold: INFO
>> - type: file
>> threshold: DEBUG
>> logFormat: "%-6level [%d{HH:mm:ss.SSS}] [%t] %logger{5} - %X{code}
>> %msg %n"
>> currentLogFilename: /var/log/dw-service.log
>> archive: true
>> archivedLogFilenamePattern:
>> /var/log/tmp/dw-service-%d{yyyy-MM-dd}-%i.log.gz
>> archivedFileCount: 3
>> timeZone: UTC
>> maxFileSize: 10MB
>>
>>
>> Ideally I would like to cause an archive of the logfile immediately on
>> startup but failing that, I would settle for getting a handle to the
>> appender and copying the file.
>>
>> I can't work out how to do either. Please could somebody offer any help?
>>
>> Thanks
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "dropwizard-dev" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Evan Meagher
>
--
You received this message because you are subscribed to the Google Groups
"dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.