FAQ
I've only been working with go for a couple of days and I have what I hope
is a very simple question about log4go.

The following code runs - not a complete program, but a portion of a
slightly larger test program:

     cmd := exec.Command("/bin/sh", "../bin/script.sh", "123")
     l4g.Warn("11111")
     out, err := cmd.Output()
     l4g.Warn("22222")

     if err != nil {
         l4g.Error(err.Error())
         os.Exit(33)
     }

     fmt.Println(string(out))
     l4g.Warn("Output = %s", string(out))

     os.Exit(0)

The shell script prints the parameter and exits. I have configured l4g to
write to the console and to a file.
The file output is:

[2015/12/23 15:07:02 UTC] [WARN] (main.main:115) 11111

and that is it. So l4g is not writing to either the console or the log file
after the shell script runs. The "fmt" statements do write correctly to the
screen.

So what do I have to do to keep log4go running properly within my program?

Incidently - if I change the path of the shell script to
"../xbin/script.not.found, then the system exits with return code 33, but
does not print the error in the log file...

Thanks in advance,

nbc

--
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/d/optout.

Search Discussions

  • Konstantin Khomoutov at Dec 23, 2015 at 5:09 pm

    On Wed, 23 Dec 2015 07:17:36 -0800 (PST) Neil Cohen wrote:

    I've only been working with go for a couple of days and I have what I
    hope is a very simple question about log4go.

    The following code runs - not a complete program, but a portion of a
    slightly larger test program:

    cmd := exec.Command("/bin/sh", "../bin/script.sh", "123")
    l4g.Warn("11111")
    out, err := cmd.Output()
    l4g.Warn("22222")

    if err != nil {
    l4g.Error(err.Error())
    os.Exit(33)
    }

    fmt.Println(string(out))
    l4g.Warn("Output = %s", string(out))

    os.Exit(0)

    The shell script prints the parameter and exits. I have configured
    l4g to write to the console and to a file.
    The file output is:

    [2015/12/23 15:07:02 UTC] [WARN] (main.main:115) 11111

    and that is it. So l4g is not writing to either the console or the
    log file after the shell script runs. The "fmt" statements do write
    correctly to the screen.

    So what do I have to do to keep log4go running properly within my
    program?
    Appears to be [1].

    If yes, I'd drop it.

    The standard log package works just okay for most cases, and if it's
    too simple for you, consider [2] or [3].

    1. http://stackoverflow.com/a/14288676/720999
    2. https://github.com/One-com/gonelog
    3. https://github.com/golang/glog

    --
    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/d/optout.
  • Neil Cohen at Dec 23, 2015 at 5:19 pm

    On Wednesday, December 23, 2015 at 12:09:36 PM UTC-5, Konstantin Khomoutov wrote:

    On Wed, 23 Dec 2015 07:17:36 -0800 (PST)
    Neil Cohen <neilbri...@gmail.com <javascript:>> wrote:
    I've only been working with go for a couple of days and I have what I
    hope is a very simple question about log4go.

    The following code runs - not a complete program, but a portion of a
    slightly larger test program:

    cmd := exec.Command("/bin/sh", "../bin/script.sh", "123")
    l4g.Warn("11111")
    out, err := cmd.Output()
    l4g.Warn("22222")

    if err != nil {
    l4g.Error(err.Error())
    os.Exit(33)
    }

    fmt.Println(string(out))
    l4g.Warn("Output = %s", string(out))

    os.Exit(0)

    The shell script prints the parameter and exits. I have configured
    l4g to write to the console and to a file.
    The file output is:

    [2015/12/23 15:07:02 UTC] [WARN] (main.main:115) 11111

    and that is it. So l4g is not writing to either the console or the
    log file after the shell script runs. The "fmt" statements do write
    correctly to the screen.

    So what do I have to do to keep log4go running properly within my
    program?
    Appears to be [1].

    If yes, I'd drop it.

    The standard log package works just okay for most cases, and if it's
    too simple for you, consider [2] or [3].

    1. http://stackoverflow.com/a/14288676/720999
    2. https://github.com/One-com/gonelog
    3. https://github.com/golang/glog

    Thanks for the info. I am not wedded to log4go - and I've found about a
    dozen different implementations of it. I was just looking for something
    along those lines that will let me configure log levels and save logs in
    arbitrary files. I will try flushing the log4go descriptor and see if that
    fixes the problem. It seems like there is no particular 'standard' for that
    so I will also investigate the other packages you mentioned.

    Thanks very much,

    nbc

    --
    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/d/optout.
  • James Bardin at Dec 24, 2015 at 2:32 pm
    It's a good idea to perform a little due diligence when you pull in coed
    like this. You didn't specify where you're getting log4go from, but the
    original repo on code.google.com has been retired and is being taken
    offline in the near future. The package was mostly abandoned as well, going
    on 4 years without a commit and many open issues.

    I can't speak for the health of any of the forks, but it seems that the
    code may have started off with the wrong approach, and came to some impasse.

    On Wednesday, December 23, 2015 at 12:18:58 PM UTC-5, Neil Cohen wrote:



    On Wednesday, December 23, 2015 at 12:09:36 PM UTC-5, Konstantin Khomoutov
    wrote:
    On Wed, 23 Dec 2015 07:17:36 -0800 (PST)
    Neil Cohen wrote:
    I've only been working with go for a couple of days and I have what I
    hope is a very simple question about log4go.

    The following code runs - not a complete program, but a portion of a
    slightly larger test program:

    cmd := exec.Command("/bin/sh", "../bin/script.sh", "123")
    l4g.Warn("11111")
    out, err := cmd.Output()
    l4g.Warn("22222")

    if err != nil {
    l4g.Error(err.Error())
    os.Exit(33)
    }

    fmt.Println(string(out))
    l4g.Warn("Output = %s", string(out))

    os.Exit(0)

    The shell script prints the parameter and exits. I have configured
    l4g to write to the console and to a file.
    The file output is:

    [2015/12/23 15:07:02 UTC] [WARN] (main.main:115) 11111

    and that is it. So l4g is not writing to either the console or the
    log file after the shell script runs. The "fmt" statements do write
    correctly to the screen.

    So what do I have to do to keep log4go running properly within my
    program?
    Appears to be [1].

    If yes, I'd drop it.

    The standard log package works just okay for most cases, and if it's
    too simple for you, consider [2] or [3].

    1. http://stackoverflow.com/a/14288676/720999
    2. https://github.com/One-com/gonelog
    3. https://github.com/golang/glog

    Thanks for the info. I am not wedded to log4go - and I've found about a
    dozen different implementations of it. I was just looking for something
    along those lines that will let me configure log levels and save logs in
    arbitrary files. I will try flushing the log4go descriptor and see if that
    fixes the problem. It seems like there is no particular 'standard' for that
    so I will also investigate the other packages you mentioned.

    Thanks very much,

    nbc
    --
    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/d/optout.
  • Neil Cohen at Dec 24, 2015 at 2:49 pm
    Due diligence is what I'm doing - I found about a dozen different forks of
    the code and I've played with a couple of them. Not sure where the
    differences are yet - I have not tried to analyze the code, but it may come
    to that... Right now, I'm just exploring the language - looking for network
    libraries, logging libraries, db libraries, and I would like to find a GUI
    library but I have not found one that looks really good yet...Suggestions
    welcome :)

    As an aside, I'm a complete newbie when it comes to Golang, but I started
    writing code in 1972. My first Unix manual was 12 pages long - for the
    entire system (!). So I'm used to the idea of digging around to figure out
    how things work. It is a lot easier these days with access to forums like
    this one - it's really good to get help from people in the community...

    Thanks...

    nbc
    On Thursday, December 24, 2015 at 9:32:15 AM UTC-5, James Bardin wrote:

    It's a good idea to perform a little due diligence when you pull in coed
    like this. You didn't specify where you're getting log4go from, but the
    original repo on code.google.com has been retired and is being taken
    offline in the near future. The package was mostly abandoned as well, going
    on 4 years without a commit and many open issues.

    I can't speak for the health of any of the forks, but it seems that the
    code may have started off with the wrong approach, and came to some impasse.

    On Wednesday, December 23, 2015 at 12:18:58 PM UTC-5, Neil Cohen wrote:



    On Wednesday, December 23, 2015 at 12:09:36 PM UTC-5, Konstantin
    Khomoutov wrote:
    On Wed, 23 Dec 2015 07:17:36 -0800 (PST)
    Neil Cohen wrote:
    I've only been working with go for a couple of days and I have what I
    hope is a very simple question about log4go.

    The following code runs - not a complete program, but a portion of a
    slightly larger test program:

    cmd := exec.Command("/bin/sh", "../bin/script.sh", "123")
    l4g.Warn("11111")
    out, err := cmd.Output()
    l4g.Warn("22222")

    if err != nil {
    l4g.Error(err.Error())
    os.Exit(33)
    }

    fmt.Println(string(out))
    l4g.Warn("Output = %s", string(out))

    os.Exit(0)

    The shell script prints the parameter and exits. I have configured
    l4g to write to the console and to a file.
    The file output is:

    [2015/12/23 15:07:02 UTC] [WARN] (main.main:115) 11111

    and that is it. So l4g is not writing to either the console or the
    log file after the shell script runs. The "fmt" statements do write
    correctly to the screen.

    So what do I have to do to keep log4go running properly within my
    program?
    Appears to be [1].

    If yes, I'd drop it.

    The standard log package works just okay for most cases, and if it's
    too simple for you, consider [2] or [3].

    1. http://stackoverflow.com/a/14288676/720999
    2. https://github.com/One-com/gonelog
    3. https://github.com/golang/glog

    Thanks for the info. I am not wedded to log4go - and I've found about a
    dozen different implementations of it. I was just looking for something
    along those lines that will let me configure log levels and save logs in
    arbitrary files. I will try flushing the log4go descriptor and see if that
    fixes the problem. It seems like there is no particular 'standard' for that
    so I will also investigate the other packages you mentioned.

    Thanks very much,

    nbc
    --
    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/d/optout.
  • James Bardin at Dec 24, 2015 at 3:14 pm
    No problem, it can be to gauge experience level when something is
    tagged as "newbie" ;)

    I haven't seen much consensus over logging packages in general, but
    glog does seem the most popular from my unscientific overview of
    golang discussions.

    Another package you can look at is http://gopkg.in/inconshreveable/log15.v2
    I'm not vouching for it, but I have seen it mentioned quite a few times.

    I think one reason that a complex logger with configurable file
    handling abilities hasn't taken over, is because it's becoming less
    common to run programs as daemons in the traditional sense (besides
    the fact that Go can't directly double-fork itself). Most services now
    can be *run* by the init system, rather than just be started by the
    init system, and the controlling process then handles logging the
    output.

    People do still often want configurable log levels, but that's easy to
    write yourself, or to just use multiple log.Loggers.

    On Thu, Dec 24, 2015 at 9:49 AM, Neil Cohen wrote:
    Due diligence is what I'm doing - I found about a dozen different forks of
    the code and I've played with a couple of them. Not sure where the
    differences are yet - I have not tried to analyze the code, but it may come
    to that... Right now, I'm just exploring the language - looking for network
    libraries, logging libraries, db libraries, and I would like to find a GUI
    library but I have not found one that looks really good yet...Suggestions
    welcome :)

    As an aside, I'm a complete newbie when it comes to Golang, but I started
    writing code in 1972. My first Unix manual was 12 pages long - for the
    entire system (!). So I'm used to the idea of digging around to figure out
    how things work. It is a lot easier these days with access to forums like
    this one - it's really good to get help from people in the community...

    Thanks...

    nbc

    On Thursday, December 24, 2015 at 9:32:15 AM UTC-5, James Bardin wrote:

    It's a good idea to perform a little due diligence when you pull in coed
    like this. You didn't specify where you're getting log4go from, but the
    original repo on code.google.com has been retired and is being taken offline
    in the near future. The package was mostly abandoned as well, going on 4
    years without a commit and many open issues.

    I can't speak for the health of any of the forks, but it seems that the
    code may have started off with the wrong approach, and came to some impasse.

    On Wednesday, December 23, 2015 at 12:18:58 PM UTC-5, Neil Cohen wrote:



    On Wednesday, December 23, 2015 at 12:09:36 PM UTC-5, Konstantin
    Khomoutov wrote:
    On Wed, 23 Dec 2015 07:17:36 -0800 (PST)
    Neil Cohen wrote:
    I've only been working with go for a couple of days and I have what I
    hope is a very simple question about log4go.

    The following code runs - not a complete program, but a portion of a
    slightly larger test program:

    cmd := exec.Command("/bin/sh", "../bin/script.sh", "123")
    l4g.Warn("11111")
    out, err := cmd.Output()
    l4g.Warn("22222")

    if err != nil {
    l4g.Error(err.Error())
    os.Exit(33)
    }

    fmt.Println(string(out))
    l4g.Warn("Output = %s", string(out))

    os.Exit(0)

    The shell script prints the parameter and exits. I have configured
    l4g to write to the console and to a file.
    The file output is:

    [2015/12/23 15:07:02 UTC] [WARN] (main.main:115) 11111

    and that is it. So l4g is not writing to either the console or the
    log file after the shell script runs. The "fmt" statements do write
    correctly to the screen.

    So what do I have to do to keep log4go running properly within my
    program?
    Appears to be [1].

    If yes, I'd drop it.

    The standard log package works just okay for most cases, and if it's
    too simple for you, consider [2] or [3].

    1. http://stackoverflow.com/a/14288676/720999
    2. https://github.com/One-com/gonelog
    3. https://github.com/golang/glog

    Thanks for the info. I am not wedded to log4go - and I've found about a
    dozen different implementations of it. I was just looking for something
    along those lines that will let me configure log levels and save logs in
    arbitrary files. I will try flushing the log4go descriptor and see if that
    fixes the problem. It seems like there is no particular 'standard' for that
    so I will also investigate the other packages you mentioned.

    Thanks very much,

    nbc
    --
    You received this message because you are subscribed to a topic in the
    Google Groups "golang-nuts" group.
    To unsubscribe from this topic, visit
    https://groups.google.com/d/topic/golang-nuts/5fXtv-rk31Y/unsubscribe.
    To unsubscribe from this group and all its topics, send an email to
    golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    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/d/optout.
  • Neil Cohen at Dec 24, 2015 at 4:33 pm
    Thanks for the pointers - I'll check out those packages. I'm mostly
    interested in a simple, multi-level logging capability at the moment.

    Happy holidays...

    nbc
    On Thursday, December 24, 2015 at 10:14:53 AM UTC-5, James Bardin wrote:

    No problem, it can be to gauge experience level when something is
    tagged as "newbie" ;)

    I haven't seen much consensus over logging packages in general, but
    glog does seem the most popular from my unscientific overview of
    golang discussions.

    Another package you can look at is
    http://gopkg.in/inconshreveable/log15.v2
    I'm not vouching for it, but I have seen it mentioned quite a few times.

    I think one reason that a complex logger with configurable file
    handling abilities hasn't taken over, is because it's becoming less
    common to run programs as daemons in the traditional sense (besides
    the fact that Go can't directly double-fork itself). Most services now
    can be *run* by the init system, rather than just be started by the
    init system, and the controlling process then handles logging the
    output.

    People do still often want configurable log levels, but that's easy to
    write yourself, or to just use multiple log.Loggers.


    On Thu, Dec 24, 2015 at 9:49 AM, Neil Cohen <neilbri...@gmail.com
    <javascript:>> wrote:
    Due diligence is what I'm doing - I found about a dozen different forks of
    the code and I've played with a couple of them. Not sure where the
    differences are yet - I have not tried to analyze the code, but it may come
    to that... Right now, I'm just exploring the language - looking for network
    libraries, logging libraries, db libraries, and I would like to find a GUI
    library but I have not found one that looks really good
    yet...Suggestions
    welcome :)

    As an aside, I'm a complete newbie when it comes to Golang, but I started
    writing code in 1972. My first Unix manual was 12 pages long - for the
    entire system (!). So I'm used to the idea of digging around to figure out
    how things work. It is a lot easier these days with access to forums like
    this one - it's really good to get help from people in the community...

    Thanks...

    nbc

    On Thursday, December 24, 2015 at 9:32:15 AM UTC-5, James Bardin wrote:

    It's a good idea to perform a little due diligence when you pull in
    coed
    like this. You didn't specify where you're getting log4go from, but the
    original repo on code.google.com has been retired and is being taken
    offline
    in the near future. The package was mostly abandoned as well, going on
    4
    years without a commit and many open issues.

    I can't speak for the health of any of the forks, but it seems that the
    code may have started off with the wrong approach, and came to some
    impasse.
    On Wednesday, December 23, 2015 at 12:18:58 PM UTC-5, Neil Cohen wrote:



    On Wednesday, December 23, 2015 at 12:09:36 PM UTC-5, Konstantin
    Khomoutov wrote:
    On Wed, 23 Dec 2015 07:17:36 -0800 (PST)
    Neil Cohen wrote:
    I've only been working with go for a couple of days and I have what
    I
    hope is a very simple question about log4go.

    The following code runs - not a complete program, but a portion of
    a
    slightly larger test program:

    cmd := exec.Command("/bin/sh", "../bin/script.sh", "123")
    l4g.Warn("11111")
    out, err := cmd.Output()
    l4g.Warn("22222")

    if err != nil {
    l4g.Error(err.Error())
    os.Exit(33)
    }

    fmt.Println(string(out))
    l4g.Warn("Output = %s", string(out))

    os.Exit(0)

    The shell script prints the parameter and exits. I have configured
    l4g to write to the console and to a file.
    The file output is:

    [2015/12/23 15:07:02 UTC] [WARN] (main.main:115) 11111

    and that is it. So l4g is not writing to either the console or the
    log file after the shell script runs. The "fmt" statements do write
    correctly to the screen.

    So what do I have to do to keep log4go running properly within my
    program?
    Appears to be [1].

    If yes, I'd drop it.

    The standard log package works just okay for most cases, and if it's
    too simple for you, consider [2] or [3].

    1. http://stackoverflow.com/a/14288676/720999
    2. https://github.com/One-com/gonelog
    3. https://github.com/golang/glog

    Thanks for the info. I am not wedded to log4go - and I've found about
    a
    dozen different implementations of it. I was just looking for
    something
    along those lines that will let me configure log levels and save logs
    in
    arbitrary files. I will try flushing the log4go descriptor and see if
    that
    fixes the problem. It seems like there is no particular 'standard' for
    that
    so I will also investigate the other packages you mentioned.

    Thanks very much,

    nbc
    --
    You received this message because you are subscribed to a topic in the
    Google Groups "golang-nuts" group.
    To unsubscribe from this topic, visit
    https://groups.google.com/d/topic/golang-nuts/5fXtv-rk31Y/unsubscribe.
    To unsubscribe from this group and all its topics, send an email to
    golang-nuts...@googlegroups.com <javascript:>.
    For more options, visit https://groups.google.com/d/optout.
    --
    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/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedDec 23, '15 at 4:54p
activeDec 24, '15 at 4:33p
posts7
users3
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase