FAQ
I'm working on a service program, which runs for months, even for years.
In my test, I found my program doesn't write syslog, while other things
goes well

Now I know the rsyslogd will move /var/log/messages as
/var/log/messages-20121118 time-cycle,

the question is, need I reopen the log file use syslog.newLogger
before every time I write log?
Or is there some better way to solve this problem?

--

Search Discussions

  • Dave Cheney at Nov 29, 2012 at 5:38 am
    Can you please post some sample code demonstrating the issue.

    To the best of my knowledge, log rolling is an implementation detail
    of syslog/rsyslog/syslog-ng and it intended to be transparent to the
    caller.
    On Thu, Nov 29, 2012 at 4:27 PM, feeling4t wrote:
    I'm working on a service program, which runs for months, even for years.
    In my test, I found my program doesn't write syslog, while other things goes
    well

    Now I know the rsyslogd will move /var/log/messages as
    /var/log/messages-20121118 time-cycle,

    the question is, need I reopen the log file use syslog.newLogger before
    every time I write log?
    Or is there some better way to solve this problem?

    --
    --
  • Feeling4t at Nov 29, 2012 at 6:45 am
    at the service init func:

    srvlog, _ := syslog.New( syslog.LOG_ERR , "myservice" )


    then I use syslog.Notice(********) / syslog.Info(********)
    / syslog.Warning(********) such things in other funcs

    the question is, when the log rolled, my program won't write log to
    /var/log/message ( of cause not, the file descriptor changed )

    and to void this, I must reopen the log file use syslog.New every time
    before writing log?



    在 2012年11月29日星期四UTC+8下午1时38分45秒,Dave Cheney写道:
    Can you please post some sample code demonstrating the issue.

    To the best of my knowledge, log rolling is an implementation detail
    of syslog/rsyslog/syslog-ng and it intended to be transparent to the
    caller.
    On Thu, Nov 29, 2012 at 4:27 PM, feeling4t wrote:
    I'm working on a service program, which runs for months, even for years.
    In my test, I found my program doesn't write syslog, while other things goes
    well

    Now I know the rsyslogd will move /var/log/messages as
    /var/log/messages-20121118 time-cycle,

    the question is, need I reopen the log file use syslog.newLogger before
    every time I write log?
    Or is there some better way to solve this problem?

    --
    --
  • David Anderson at Nov 29, 2012 at 6:51 am

    On Wed, Nov 28, 2012 at 10:45 PM, feeling4t wrote:

    at the service init func:

    srvlog, _ := syslog.New( syslog.LOG_ERR , "myservice" )
    You're ignoring the error return value. Therefore, you have no idea if the
    creation of the syslog object actually succeeded.

    srvlog, err := syslog.New(syslog.LOG_ERR, "myservice")
    if err != nil {
    log.Fatalf("Couldn't start syslog writer: %s", err)
    }

    If you ignore errors, you should not expect anything to work.

    - Dave


    then I use syslog.Notice(********) / syslog.Info(********)
    / syslog.Warning(********) such things in other funcs

    the question is, when the log rolled, my program won't write log to
    /var/log/message ( of cause not, the file descriptor changed )

    and to void this, I must reopen the log file use syslog.New every time
    before writing log?



    在 2012年11月29日星期四UTC+8下午1时38分45秒,Dave Cheney写道:
    Can you please post some sample code demonstrating the issue.

    To the best of my knowledge, log rolling is an implementation detail
    of syslog/rsyslog/syslog-ng and it intended to be transparent to the
    caller.
    On Thu, Nov 29, 2012 at 4:27 PM, feeling4t wrote:
    I'm working on a service program, which runs for months, even for years.
    In my test, I found my program doesn't write syslog, while other things goes
    well

    Now I know the rsyslogd will move /var/log/messages as
    /var/log/messages-20121118 time-cycle,

    the question is, need I reopen the log file use syslog.newLogger before
    every time I write log?
    Or is there some better way to solve this problem?

    --
    --

    --
  • Feeling4t at Nov 29, 2012 at 7:16 am
    I think it's not the point, syslog.New only called once at the beginning of
    the program, and this program will run for months
    At the first few days, it goes well, writes logs to /var/log/messages
    but after log rolled, I mean the system move /var/log/messages to
    /var/log/messages[date], and make a new /var/log/messages, the program
    doesn't write logs to /var/log/messages

    在 2012年11月29日星期四UTC+8下午2时51分16秒,David Anderson写道:
    On Wed, Nov 28, 2012 at 10:45 PM, feeling4t <feel...@gmail.com<javascript:>
    wrote:
    at the service init func:

    srvlog, _ := syslog.New( syslog.LOG_ERR , "myservice" )
    You're ignoring the error return value. Therefore, you have no idea if the
    creation of the syslog object actually succeeded.

    srvlog, err := syslog.New(syslog.LOG_ERR, "myservice")
    if err != nil {
    log.Fatalf("Couldn't start syslog writer: %s", err)
    }

    If you ignore errors, you should not expect anything to work.

    - Dave


    then I use syslog.Notice(********) / syslog.Info(********)
    / syslog.Warning(********) such things in other funcs

    the question is, when the log rolled, my program won't write log to
    /var/log/message ( of cause not, the file descriptor changed )

    and to void this, I must reopen the log file use syslog.New every time
    before writing log?



    在 2012年11月29日星期四UTC+8下午1时38分45秒,Dave Cheney写道:
    Can you please post some sample code demonstrating the issue.

    To the best of my knowledge, log rolling is an implementation detail
    of syslog/rsyslog/syslog-ng and it intended to be transparent to the
    caller.
    On Thu, Nov 29, 2012 at 4:27 PM, feeling4t wrote:
    I'm working on a service program, which runs for months, even for years.
    In my test, I found my program doesn't write syslog, while other
    things goes
    well

    Now I know the rsyslogd will move /var/log/messages as
    /var/log/messages-20121118 time-cycle,

    the question is, need I reopen the log file use syslog.newLogger before
    every time I write log?
    Or is there some better way to solve this problem?

    --
    --

    --
  • Dave Cheney at Nov 29, 2012 at 6:52 am
    Mate, you're ignoring the error.

    Also, syslog, from the point of view of the produce knows nothing
    about the final log files (yes, generally syslog output goes to
    several locations), it only knows about the unix domain socket that
    syslogd listens on.
    On Thu, Nov 29, 2012 at 5:45 PM, feeling4t wrote:
    at the service init func:

    srvlog, _ := syslog.New( syslog.LOG_ERR , "myservice" )


    then I use syslog.Notice(********) / syslog.Info(********) /
    syslog.Warning(********) such things in other funcs

    the question is, when the log rolled, my program won't write log to
    /var/log/message ( of cause not, the file descriptor changed )

    and to void this, I must reopen the log file use syslog.New every time
    before writing log?



    在 2012年11月29日星期四UTC+8下午1时38分45秒,Dave Cheney写道:
    Can you please post some sample code demonstrating the issue.

    To the best of my knowledge, log rolling is an implementation detail
    of syslog/rsyslog/syslog-ng and it intended to be transparent to the
    caller.
    On Thu, Nov 29, 2012 at 4:27 PM, feeling4t wrote:
    I'm working on a service program, which runs for months, even for years.
    In my test, I found my program doesn't write syslog, while other things
    goes
    well

    Now I know the rsyslogd will move /var/log/messages as
    /var/log/messages-20121118 time-cycle,

    the question is, need I reopen the log file use syslog.newLogger before
    every time I write log?
    Or is there some better way to solve this problem?

    --
    --
    --
  • Feeling4t at Nov 29, 2012 at 7:24 am
    I made a test:

    func main () {
    srvlog, err := syslog.New( syslog.LOG_ERR , "golog" )
    if err != nil {
    println("Log start err")
    }
    for {
    time.Sleep(2*time.Second)
    srvlog.Notice("write log")
    }
    }


    After this program run, I can see it writes logs in /var/log/messages, but
    after restart the rsyslog service, it won't write logs.
    So, the socket is not fixed?

    在 2012年11月29日星期四UTC+8下午2时52分08秒,Dave Cheney写道:
    Mate, you're ignoring the error.

    Also, syslog, from the point of view of the produce knows nothing
    about the final log files (yes, generally syslog output goes to
    several locations), it only knows about the unix domain socket that
    syslogd listens on.
    On Thu, Nov 29, 2012 at 5:45 PM, feeling4t wrote:
    at the service init func:

    srvlog, _ := syslog.New( syslog.LOG_ERR , "myservice" )


    then I use syslog.Notice(********) / syslog.Info(********) /
    syslog.Warning(********) such things in other funcs

    the question is, when the log rolled, my program won't write log to
    /var/log/message ( of cause not, the file descriptor changed )

    and to void this, I must reopen the log file use syslog.New every time
    before writing log?



    在 2012年11月29日星期四UTC+8下午1时38分45秒,Dave Cheney写道:
    Can you please post some sample code demonstrating the issue.

    To the best of my knowledge, log rolling is an implementation detail
    of syslog/rsyslog/syslog-ng and it intended to be transparent to the
    caller.
    On Thu, Nov 29, 2012 at 4:27 PM, feeling4t wrote:
    I'm working on a service program, which runs for months, even for
    years.
    In my test, I found my program doesn't write syslog, while other
    things
    goes
    well

    Now I know the rsyslogd will move /var/log/messages as
    /var/log/messages-20121118 time-cycle,

    the question is, need I reopen the log file use syslog.newLogger
    before
    every time I write log?
    Or is there some better way to solve this problem?

    --
    --
    --
  • Dave Cheney at Nov 29, 2012 at 7:28 am
    Right, ok, now we're getting to the real issue.

    I believe you are reporting issue
    https://code.google.com/p/go/issues/detail?id=2264
    On Thu, Nov 29, 2012 at 6:24 PM, feeling4t wrote:
    I made a test:

    func main () {
    srvlog, err := syslog.New( syslog.LOG_ERR , "golog" )
    if err != nil {
    println("Log start err")
    }
    for {
    time.Sleep(2*time.Second)
    srvlog.Notice("write log")
    }
    }


    After this program run, I can see it writes logs in /var/log/messages, but
    after restart the rsyslog service, it won't write logs.
    So, the socket is not fixed?

    在 2012年11月29日星期四UTC+8下午2时52分08秒,Dave Cheney写道:
    Mate, you're ignoring the error.

    Also, syslog, from the point of view of the produce knows nothing
    about the final log files (yes, generally syslog output goes to
    several locations), it only knows about the unix domain socket that
    syslogd listens on.
    On Thu, Nov 29, 2012 at 5:45 PM, feeling4t wrote:
    at the service init func:

    srvlog, _ := syslog.New( syslog.LOG_ERR , "myservice" )


    then I use syslog.Notice(********) / syslog.Info(********) /
    syslog.Warning(********) such things in other funcs

    the question is, when the log rolled, my program won't write log to
    /var/log/message ( of cause not, the file descriptor changed )

    and to void this, I must reopen the log file use syslog.New every time
    before writing log?



    在 2012年11月29日星期四UTC+8下午1时38分45秒,Dave Cheney写道:
    Can you please post some sample code demonstrating the issue.

    To the best of my knowledge, log rolling is an implementation detail
    of syslog/rsyslog/syslog-ng and it intended to be transparent to the
    caller.
    On Thu, Nov 29, 2012 at 4:27 PM, feeling4t wrote:
    I'm working on a service program, which runs for months, even for
    years.
    In my test, I found my program doesn't write syslog, while other
    things
    goes
    well

    Now I know the rsyslogd will move /var/log/messages as
    /var/log/messages-20121118 time-cycle,

    the question is, need I reopen the log file use syslog.newLogger
    before
    every time I write log?
    Or is there some better way to solve this problem?

    --
    --
    --
    --
  • Feeling4t at Nov 29, 2012 at 9:01 am
    thx a lot

    one more question, it was reported and fixed at r59, why it still in go1,
    which the version I am using
    will it be fixed in later version?



    在 2012年11月29日星期四UTC+8下午3时28分49秒,Dave Cheney写道:
    Right, ok, now we're getting to the real issue.

    I believe you are reporting issue
    https://code.google.com/p/go/issues/detail?id=2264
    On Thu, Nov 29, 2012 at 6:24 PM, feeling4t wrote:
    I made a test:

    func main () {
    srvlog, err := syslog.New( syslog.LOG_ERR , "golog" )
    if err != nil {
    println("Log start err")
    }
    for {
    time.Sleep(2*time.Second)
    srvlog.Notice("write log")
    }
    }


    After this program run, I can see it writes logs in /var/log/messages, but
    after restart the rsyslog service, it won't write logs.
    So, the socket is not fixed?

    在 2012年11月29日星期四UTC+8下午2时52分08秒,Dave Cheney写道:
    Mate, you're ignoring the error.

    Also, syslog, from the point of view of the produce knows nothing
    about the final log files (yes, generally syslog output goes to
    several locations), it only knows about the unix domain socket that
    syslogd listens on.
    On Thu, Nov 29, 2012 at 5:45 PM, feeling4t wrote:
    at the service init func:

    srvlog, _ := syslog.New( syslog.LOG_ERR , "myservice" )


    then I use syslog.Notice(********) / syslog.Info(********) /
    syslog.Warning(********) such things in other funcs

    the question is, when the log rolled, my program won't write log to
    /var/log/message ( of cause not, the file descriptor changed )

    and to void this, I must reopen the log file use syslog.New every
    time
    before writing log?



    在 2012年11月29日星期四UTC+8下午1时38分45秒,Dave Cheney写道:
    Can you please post some sample code demonstrating the issue.

    To the best of my knowledge, log rolling is an implementation detail
    of syslog/rsyslog/syslog-ng and it intended to be transparent to the
    caller.
    On Thu, Nov 29, 2012 at 4:27 PM, feeling4t wrote:
    I'm working on a service program, which runs for months, even for
    years.
    In my test, I found my program doesn't write syslog, while other
    things
    goes
    well

    Now I know the rsyslogd will move /var/log/messages as
    /var/log/messages-20121118 time-cycle,

    the question is, need I reopen the log file use syslog.newLogger
    before
    every time I write log?
    Or is there some better way to solve this problem?

    --
    --
    --
    --
  • Minux at Nov 29, 2012 at 9:24 am

    On Thu, Nov 29, 2012 at 5:01 PM, feeling4t wrote:

    one more question, it was reported and fixed at r59, why it still in go1,
    which the version I am using
    will it be fixed in later version?
    issue 2264 is still marked state accepted, it's not fixed.

    i think we should raise its priority to Go1.1, IMO this is a serious bug.
    I hope the recent CLs that try to make log/syslog more standard compliant
    could address this issue.

    --

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedNov 29, '12 at 5:27a
activeNov 29, '12 at 9:24a
posts10
users4
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase