Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'logs' directory is made automatically #99

Closed
aszkid opened this issue Aug 27, 2013 · 14 comments
Closed

'logs' directory is made automatically #99

aszkid opened this issue Aug 27, 2013 · 14 comments
Milestone

Comments

@aszkid
Copy link

aszkid commented Aug 27, 2013

I've been playing around and have noticed that, no matter if my configuration specifically defines a file as follows:

    * GLOBAL:
        FORMAT               =  "%datetime %log"
        FILENAME             =  "../my.log"
        ENABLED              =  true
        TO_FILE              =  true
        TO_STANDARD_OUTPUT   =  true
        MILLISECONDS_WIDTH   =  6
        PERFORMANCE_TRACKING =  true
        MAX_LOG_FILE_SIZE    =  2097152
    * DEBUG:
        FORMAT               = "%datetime{%d/%M/%Y %h:%n:%s} %log"

A folder 'logs' and empty file 'myeasylog.log' is made (inside the folder). Is that supposed to happen? Is there any way to avoid the creation of the folder and file?

@easylogging
Copy link
Contributor

Hey,

Yup there is a way to avoid it - or more specifically to change it - this is necessary as this is the starting configuration (and then when you re-configure, it just re-assigns it)

The way you change it is macro definition during compilation or above #include "easylogging++.h"

Macro name is _ELPP_DEFAULT_LOG_FILE and value will be filepath you want, (may be /tmp/my-tmp-file.log?) Have a look at the last macro on Configuration Macros section.

PLease let me know if you can think of any alternative way of implementation :)

EDIT: And you have typo in DEBUG date format, i think you need %m :) instead of %n
hope this helps

@easylogging
Copy link
Contributor

I have come up with a solution to this and will implement this in v9.13

@easylogging
Copy link
Contributor

Fixed in v9.13 :) - look for macro name _ELPP_NO_DEFAULT_LOG_FILE in Configuration Macros section of manual

feel free to check out release notes for v9.12 (released yesterday) and v9.13

@aszkid
Copy link
Author

aszkid commented Aug 28, 2013

Thanks for you attention and the feature addition, but i'm getting an assertion with the expression 'map/set iterator not dereferencable' right when the debugger steps over _INITIALIZE_EASYLOGGINGPP. Something's wrong, because if i remove the definition of the macro _ELPP_NO_DEFAULT_LOG_FILE, it works, but it (obviously) creates the folder and log file.

error

I'll spend some time and go over the easylogging file, to see if i can help to correct bugs as i encounter them. Thanks a lot for your hard work!

@easylogging
Copy link
Contributor

All good :)

Sorry about that, try v9.14 and let me know if this issue is still there - currently i am travelling so I cant test on my windows machine

@easylogging
Copy link
Contributor

Also if you are worried about compile warnings - they have been fixed in v9.15

@easylogging
Copy link
Contributor

Confirmed - its working with VC++ (and other compilers) provided you dont try to log before configuration

@aszkid
Copy link
Author

aszkid commented Aug 28, 2013

Ugh, then i'm doing something wrong, because with 9.16 i still get that assertion error:

ohnoes

@easylogging
Copy link
Contributor

I retried with the code in your screenshot and my guess is your configuration file path is not correct- please find two attachments, one with invalid path where i do get assertion failure (as expected because I am trying to write to file that does not yet exist hence not pointer to it is not derefernecable) and other with correct configuration path which works good
invalid-path
correct-path

Try it with fully qualified path

or alternatively using

el::Loggers::reconfigureAllLoggers(el::ConfigurationType::Filename, "../my.log"); before you start logging anything including CHECK macros

@easylogging
Copy link
Contributor

I tried relative path and it works for me as well - e.g, in VC++ sample \samples\VC++\VCPP2012_Win32_Multithreaded I put my configuration file there and used same relative path as yours with my file conf.txt and its logging to correct place and picking up from correct place

I think to be on safe side always use
el::Loggers::reconfigureAllLoggers(el::ConfigurationType::Filename, "../my.log"); before trying to configure using configuration file, that way you will always know if it can't find configuratoin file - it will log to my.log anyway

@easylogging
Copy link
Contributor

I have created issue #102 for v9.17 release

@aszkid
Copy link
Author

aszkid commented Aug 28, 2013

This is weird:

what

If i take the NO_DEFAULT_LOG_FILE macro out, it works.

@easylogging
Copy link
Contributor

Well it is weird. Can u plz make sure u have at least v9.15 if not any higher? You can see it from top of header file

@easylogging
Copy link
Contributor

And one more thinn u have braces around easylogging ++ header which means the preferred search path is include path. Can u plz make sure when u look for version u look at correct file thst vs2012 is picking up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants