Questions tagged [logging]

Computer data logging is the process of recording events in a computer program or computer system, usually with a certain scope, in order to provide an audit trail that can be used to understand the activity of the system and to diagnose problems. Be sure to include appropriate software or hardware tags in addition to this tag.

Logging

Computer data logging is the process of recording events in a computer program, usually with a certain scope, in order to provide an audit trail that can be used to understand the activity of the system and to diagnose problems. Logs are essential to understand the activities of complex systems, particularly in the case of applications with little user interaction (such as server applications).

Examples

Examples of physical systems which have logging subsystems include process control systems, and black box recorders installed in aircraft.

Many operating systems and complex computer programs include some form of logging subsystem. In the simplest case, log messages are written to a log file. Most operating systems and software frameworks also provide more sophisticated services for logging. One example is the syslog service (described in RFC 3164), which allows the filtering and recording of log messages to be performed by a separate dedicated subsystem, rather than placing the onus on each application to provide its own ad hoc logging system.

A server log is a log file (or several files) automatically created and maintained by a server of activity performed by it. A typical example is a web server log which maintains a history of page requests.

An audit log is a security-related log that provides documentary evidence of the sequence of activities that have affected at any time a specific operation, procedure, or event.

Standards

SysLog

Syslog is an informal standard for computer data logging that was developed in the 1980s by Eric Allman. It was created solely for Sendmail but proved so valuable that other applications began using it as well. It has since become the standard logging solution on Unix and Unix-like systems; there have also been a variety of implementations on other operating systems and it is commonly found in network devices such as routers.

The Internet Engineering Task Force has documented (but not formalized) the standard in RFC 5424.

Common Log Format

The Common Log Format (also known as the NCSA Common log format) and Extended Log Format are standardized text file formats used by web servers when generating log files. Because the formats are standardized, the files generated may be analyzed by a variety of web analysis programs.

Common Log Format entries take the form:

host ident authuser date request status bytes

Eg: 127.0.0.1 user-identifier frank [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326


References

41059 questions
178
votes
11 answers

How to send a stacktrace to log4j?

Say you catch an exception and get the following on the standard output (like, say, the console) if you do a e.printStackTrace() : java.io.FileNotFoundException: so.txt at java.io.FileInputStream.(FileInputStream.java) at…
SyntaxT3rr0r
  • 27,745
  • 21
  • 87
  • 120
178
votes
6 answers

Is there a "vim runtime log"?

Sometimes I try a customization/command in my vimrc. Everything seens to be correct, but it just doesn't work. It's difficult to know what's happening when vim starts, and know which command failed or not, so it's really difficult to debug what can…
178
votes
12 answers

How do I convert dmesg timestamp to custom date format?

I am trying to understand the dmesg timestamp and find it hard to convert that to change it to java date/custom date format. Sample dmesg log: [14614.647880] airo(eth1): link lost (missed beacons) So how do I convert 14614.647880 to a standard…
ukanth
  • 2,718
  • 5
  • 28
  • 38
177
votes
12 answers

How can I configure Logback to log different levels for a logger to different destinations?

How can I configure Logback to log different levels for a logger to different destinations? For example, given the following Logback configuration, will Logback record INFO messages to STDOUT and ERROR messages to STDERR? (Note that this example is…
Derek Mahar
  • 27,608
  • 43
  • 124
  • 174
177
votes
11 answers

How to change maven logging level to display only warning and errors?

I want to prevent maven from displaying INFO messages, I want to see only WARNINGS and ERRORS (if any). How can I achieve this, preferably by changing the command line that calls maven?
sorin
  • 161,544
  • 178
  • 535
  • 806
175
votes
7 answers

In python, why use logging instead of print?

For simple debugging in a complex project is there a reason to use the python logger instead of print? What about other use-cases? Is there an accepted best use-case for each (especially when you're only looking for stdout)? I've always heard that…
Sam Odio
  • 2,717
  • 5
  • 22
  • 25
175
votes
3 answers

log4j: Log output of a specific class to a specific appender

I use log4j and would like to route the output of certain Loggers to specific files. I already have multiple appenders in place. Now, to make debugging easier, I want to tell log4j that the output generated by a specific class (e.g. foo.bar.Baz)…
gubrutz
  • 1,753
  • 2
  • 11
  • 4
174
votes
19 answers

How to add a custom loglevel to Python's logging facility

I'd like to have loglevel TRACE (5) for my application, as I don't think that debug() is sufficient. Additionally log(5, msg) isn't what I want. How can I add a custom loglevel to a Python logger? I've a mylogger.py with the following…
tuergeist
  • 9,171
  • 3
  • 37
  • 58
174
votes
6 answers

Database design for audit logging

Every time I need to design a new database I spend quite some time thinking on how I should set up the database schema to keep an audit log of the changes. Some questions have already been asked here about this, but I don't agree that there is a…
jbochi
  • 28,816
  • 16
  • 73
  • 90
174
votes
6 answers

log4j vs logback

We are using log4j behind a selfmade wrapper. We plan to use much more features of it now. Should we update to logback ? (I mean the framework not a facade like SLF4J)
TimmiB
173
votes
10 answers

How to write logs in text file when using java.util.logging.Logger

I have a situation in which I want to write all logs created by me into a text file. We are using java.util.logging.Logger API to generate the logs. I tried: private static Logger logger = Logger.getLogger(className.class.getName()); FileHandler fh;…
Pankaj
  • 2,057
  • 3
  • 15
  • 10
172
votes
3 answers

Logback to log different messages to two files

I am using logback/slf4j to do my logging. I want to parse my log file to analyze some data, so instead of parsing a great big file (mostly consisting of debug statements) I want to have two logger instances which each log to a separate file; one…
Aly
  • 15,865
  • 47
  • 119
  • 191
171
votes
9 answers

How to log something in Rails in an independent log file?

In rails I want to log some information in a different log file and not the standard development.log or production.log. I want to do this logging from a model class.
akshat
  • 15,472
  • 8
  • 30
  • 29
169
votes
10 answers

How to change root logging level programmatically for logback

I have the following logback.xml file: %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} -…
Kai Sternad
  • 22,214
  • 7
  • 47
  • 42
168
votes
13 answers

Log4net does not write the log in the log file

I have created a simple scenario using Log4net, but it seems that my log appenders do not work because the messages are not added to the log file. I added the following to the web.config file:
john84
  • 2,431
  • 4
  • 24
  • 30