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

How to add data when logging #1

Closed
svetlyak40wt opened this issue Sep 9, 2016 · 9 comments
Closed

How to add data when logging #1

svetlyak40wt opened this issue Sep 9, 2016 · 9 comments

Comments

@svetlyak40wt
Copy link

Hi, guys!

README says that on of the goals is Context sensitive logging (easily use the dynamic context to add to the data being logged). I didn't find any examples or sources how to use this.

Is this feature implemented?

What I want is something like that:

CL-USER> (let ((value 1)
                           (another 3))
    (with-context (:some value :another value)
        (log.debug "Blah minor"))

"{\"message\": \"Blah minor\", \"fields\": {\"some\": 1, \"another\": 3}}"
@bobbysmith007
Copy link
Member

Sorry the README was incomplete - there is a lot of possible ways to log and all of them are a bit complex. Yes you can definitely provide environment information the way that you have above as I have added to the README. Please let me know if that helps. We use this to log timing data about functions in one of our long running applications. It helps us know what the slowest parts of the system are over time

@svetlyak40wt
Copy link
Author

Thank you, @bobbysmith007 !

By the way, guys, why didn't you write a appender to log4cl and invented your own logging library?

@bobbysmith007
Copy link
Member

Well I had a ton of libraries already written with arnesi logging and I had specify goals that didn't seem to be covered by any other loggers, meaning I would putting a good amount of work into one of these libraries. I don't remember all the factors at this point, but in the end the decision was made to improve upon the log library we were using. Arnesi is largely unmaintained and a blob of many different tools, so as I went i separated it into its own repo, so folks would not have to include all of arnesi. The main motivation was logging program context data into log stash which has Json formatted log messages.

@bobbysmith007
Copy link
Member

I have an internal ticket with some analysis on it somewhere I could dig up if you want.

Similar with lisp-unit2. I had lots of tests written in lisp-unit and goals none of the existing libs met, and after deliberation, I decided to improve lisp-unit instead of a different library (steffil seemed closest to my needs). After all my changes, there were some backward compatibility issues that made branching worth while.

Coincidentally, one of the big changes to both these systems is much heavier use of signals and restarts to allow better control from the program including these libs.

@svetlyak40wt
Copy link
Author

Thank you for lengthy answer. Actually, I started to write a custom appender for log4cl for json serialization and context data collection.

@bobbysmith007
Copy link
Member

One other thing that I forgot, for my environment (sbcl/swank), this a-cl-logger logs with presentation streams which allows inspecting items in a log message from the repl.

Our of curiosity, why did you choose log4cl over the other choices?

@svetlyak40wt
Copy link
Author

log4cl seems very mature, doen't require many setup code. Also, it is used in some opensource libraries, so I automatically will see logging from them. Any finally, I've read this comparison article: https://sites.google.com/site/sabraonthehill/comparison-of-lisp-logging-libraries

And also, I've heard log4cl have good integration with slime.

@bobbysmith007
Copy link
Member

Neat I hadn't seen that article, thanks for the link.

@svetlyak40wt
Copy link
Author

You welcome! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants