FAQ
Hi,

I've been using Go for a while now and really like it. I was also
pleasantly surprised to find a log4go - a library very similar to log4j
which I am very familiar with.

I have a fairly simple app that needs only one log file and I have defined
my 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">10M</property> <!-- \d+[KMG]? Suffixes are in
terms of 2**10 -->
<property name="maxlines">1K</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.

Does anyone know what it is have got wrong with this or what changes I need
to make?

Thanks in advance
Nathan

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Kyle Lemons at Mar 6, 2013 at 7:11 pm

    On Wed, Mar 6, 2013 at 8:13 AM, wrote:

    Hi,

    I've been using Go for a while now and really like it. I was also
    pleasantly surprised to find a log4go - a library very similar to log4j
    which I am very familiar with.

    I have a fairly simple app that needs only one log file and I have defined
    my 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">10M</property> <!-- \d+[KMG]? Suffixes are in
    terms of 2**10 -->
    <property name="maxlines">1K</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.

    Does anyone know what it is have got wrong with this or what changes I
    need to make?
    Hmm. Sounds like a bug ><.

    File an issue? https://code.google.com/p/log4go/issues/list

    Thanks in advance
    Nathan

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedMar 6, '13 at 7:05p
activeMar 6, '13 at 7:11p
posts2
users2
websitegolang.org

2 users in discussion

Kyle Lemons: 1 post Ndavies: 1 post

People

Translate

site design / logo © 2022 Grokbase