cihub/seelog-examples

[Q]More explaination and examples rollingfile ?

Opened this issue · 6 comments

I need more demos in WIKI.

We have all its parameters described in our wiki. Please tell me if I left any parameters undocumented, I'll fix it.

How do I get func stacks when a error occurs ?

What does the "exception" mean , panic or error ? I am Java-Developer , I am a little confused about seelog exception.

If you are talking about seelog exceptions, then they don't have anything to do with golang errors or panics or the Exception concept in other programming languages (like in Java or .NET). This is just our local term used in log configs.

From our wiki page:

Exceptions, as opposed to general rules, are thought as special cases which break (loosen or strengthen) the regular rules (general constraints).

It is like when you have a general rule and you have exceptions to that rule. Like your minimal logging level for your application is 'INFO', but you have one exception to that rule: for a specific file you use, say, 'DEBUG'.

This can be illustrated by the following config part:

<seelog minlevel="info">
    <exceptions>
        <exception filepattern="some/file/path" minlevel="debug"/>
    </exceptions>
...

Currently we don't have a special formatter to print a stack trace.

So, answering your question, if you need to log an error stack trace, you can do something like:

import "runtime/debug"
...
seelog.Errorf("Error: %s. Stack: %s", err, debug.Stack())

But I'm not sure why you would want that for errors. If you want to deal with panics (which are closer to Java exceptions), then you need to use recover and you'll get its stack. Then you can log it, if needed.

Hope that makes sense.

I encourage you to read our wiki, it should have pretty much all answers to seelog-related questions as it covers all of its current functionality.

I need to know what happened when the error occur .

As you said:

But I'm not sure why you would want that for errors. If you want to deal with panics (which are closer to Java exceptions), then you need to use recover and you'll get its stack. Then you can log it, if needed.

Hope that makes sense.