logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Middleton <osfan6...@gmail.com>
Subject Re: How to find log file name?
Date Tue, 23 Aug 2016 01:25:52 GMT
Dave,

Depending on your specific use case, it may be easier to simply log to a
well-known location on the system and point the user to that location.  At
least one problem with trying to figure out the location programatically is
that a single logger can log to multiple sources at once, e.g. multiple
files or to a database.

Regardless, you can probably use the following sequence(note: I have not
tried this myself)


   1. Get the logger that you want to get the appender for(that is, you
   must have a logger that logs to the file you want to get the name of)
   2. Use logger.getAppender( std::string name ) or logger.getAppenders()
   and loop through all of the appenders.
   3. Figure out which of the appenders is a FileAppender:
   https://logging.apache.org/log4cxx/latest_stable/apidocs/classlog4cxx_1_1_file_appender.html
   (I think you need to use dynamic_cast here, but I'm not positive, I don't
   do much casting in C++)
   4. Call the FileAppender.getFile() method.

-Robert Middleton

On Mon, Aug 22, 2016 at 6:48 PM, Dave Birdsall <dave.birdsall@esgyn.com>
wrote:

> Hi,
>
>
>
> I’m a newbie to log4cxx (and lack familiarity with log4j).
>
>
>
> I have what is likely a naïve question.
>
>
>
> Suppose I am about to log some information to a log file. I’d like to tell
> my user where that log file is (the path and file name) so the user doesn’t
> have to hunt for it. Is there a programmatic way to obtain the log file
> name?
>
>
>
> Thanks,
>
>
>
> Dave
>

Mime
View raw message