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

Log file rotation not happening #14

Open
GoogleCodeExporter opened this issue Dec 19, 2015 · 2 comments
Open

Log file rotation not happening #14

GoogleCodeExporter opened this issue Dec 19, 2015 · 2 comments

Comments

@GoogleCodeExporter
Copy link

Version/System Details
======================
GoLang version 1.0.3
OS: Issue on Windows 7 and Debian linux
log4go version 3.0.1

Issue Description
=================
I have a fairly simple app that needs only one log file and I have defined my 
log4ggo configuration as follows:

<logging>
  <filter enabled="false">
    <tag>stdout</tag>
    <type>console</type>
    <!-- level is (:?FINEST|FINE|DEBUG|TRACE|INFO|WARNING|ERROR) -->
    <level>DEBUG</level>
  </filter>
  <filter enabled="true">
    <tag>AppLog</tag>
    <type>file</type>
    <level>DEBUG</level>
    <property name="format">[%D %T] [%L] (%S) %M</property>
    <property name="filename">app/log/main.log</property>
    <property name="rotate">false</property> <!-- true enables log rotation, otherwise append -->
    <property name="maxsize">5M</property> <!-- \d+[KMG]? Suffixes are in terms of 2**10 -->
    <property name="maxlines">0K</property> <!-- \d+[KMG]? Suffixes are in terms of thousands -->
    <property name="daily">false</property> <!-- Automatically rotates when a log message is written after midnight -->
  </filter>
</logging>

This creates the log file, it creates only one file and does not generate new 
files when the thresholds are met. You will see that I have rotate set to 
false. If I set 
    <property name="rotate">true</property> <!-- true enables log rotation, otherwise append -->
then the application when running writes every log line to a new file. 
Eventually it crashes as it has written so many log files it cannot generate a 
new unique log number this happens after main.log.999

What I would like is to keep a set of say 10 log files that are max size 5MB; 
in the same way the log4j works for Java.

Thanks for writing this library and making it available, on the whole it is an 
excellent package, thanks for you r efforts on it.

Original issue reported on code.google.com by [email protected] on 7 Mar 2013 at 10:11

@GoogleCodeExporter
Copy link
Author

Hi, 

I have to admit a little user error here. I was issuing:
l4g.LoadConfiguration()
in every func that I wanted logging and while this used the same file it was 
unnecessary.

I have changed my code base and can confirm that if rotate is set to true and 
the file size rotation is set then the behaviour is as expected.

One thing I would like is a way to set how many files to retain so that the log 
directory doesn't get clogged.

Thanks
Nathan

Original comment by [email protected] on 13 Mar 2013 at 11:30

@GoogleCodeExporter
Copy link
Author

Hi

Is there a way to limit the number of log files created? I'm looking for 
circular log rotation similar to Java's log4j.

Thanks
Prakash

Original comment by [email protected] on 4 May 2015 at 9:01

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

1 participant