Questions tagged [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.

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

Courtesy of SO tag logging

262 questions
169
votes
3 answers

Benefits of Structured Logging vs basic logging

We're building a new app and I'd like to include structured logging. My ideal setup would be something like Serilog for our C# code, and Bunyan for our JS. These would feed into fluentd and then could go out to any number of things, I was thinking…
DTI-Matt
  • 1,799
  • 2
  • 10
  • 5
137
votes
6 answers

Why does the TRACE level exist, and when should I use it rather than DEBUG?

In Log4J, Slf4J and a couple other logging frameworks in Java, you have two "developper" level for logging: DEBUG TRACE I understand what DEBUG does, because the explanation is clear: The DEBUG Level designates fine-grained informational events…
Laurent Bourgault-Roy
  • 5,606
  • 4
  • 20
  • 25
87
votes
14 answers

Why do most log files use plain text rather than a binary format?

Logging is something that is necessary but is (relatively) rarely used. As such it can be made much more compact in terms of storage. For example the data most commonly logged like ip, date, time and other data that can be represented as an integer…
php_nub_qq
  • 2,204
  • 4
  • 17
  • 25
74
votes
9 answers

What are some patterns and anti-patterns of application logging?

I recently had to investigate a field issue for our large enterprise application. I was horrified by the logs that I had to comb through in an attempt to find the problem and at the end of the day the logs did not help at all identifying/isolating…
c_maker
  • 8,250
  • 4
  • 35
  • 53
54
votes
3 answers

Best practices for logging and tracing in .NET

I've been reading a lot about tracing and logging, trying to find some golden rule for best practices in the matter, but there isn't any. People say that good programmers produce good tracing, but put it that way and it has to come from…
Levidad
  • 798
  • 1
  • 7
  • 10
45
votes
8 answers

Why doesn't "object reference not set to an instance of an object" tell us which object?

We're launching a system, and we sometimes get the famous exception NullReferenceException with the message Object reference not set to an instance of an object. However, in a method where we have almost 20 objects, having a log which says an…
Saeed Neamati
  • 18,142
  • 23
  • 87
  • 125
44
votes
11 answers

Logging: Why and What?

I've never written programs which make significant use of logging. The most I've done is to capture stack traces when exceptions happen. I was wondering, how much do other people log? Does it depend what kind of application you are writing? Do you…
Winston Ewert
  • 24,732
  • 12
  • 72
  • 103
43
votes
9 answers

Do we need Logging when doing TDD?

When doing the Red, Green & Refactor cycle we should always write the minimum code to pass the test. This is the way I have been taught about TDD and the way almost all books describe the process. But what about the logging? Honestly I have rarely…
Songo
  • 6,548
  • 4
  • 48
  • 89
42
votes
2 answers

Should You Log From Library Code?

If I am developing a Java library, is it good practice to issue log statements from within the library's code? Having logging within the library will make debugging and troubleshooting more transparent. However, on the other hand, I do not like…
Danish
  • 575
  • 1
  • 5
  • 7
39
votes
6 answers

Making code findable by using globally unique message IDs

A common pattern for locating a bug follows this script: Observe weirdness, for example, no output or a hanging program. Locate relevant message in log or program output, for example, "Could not find Foo". (The following is only relevant if this is…
l0b0
  • 11,014
  • 2
  • 43
  • 47
38
votes
6 answers

Try/Catch/Log/Rethrow - Is Anti Pattern?

I can see several post where importance of handling exception at central location or at process boundary been emphasized as a good practice rather than littering every code block around try/catch. I strongly believe that most of us understand the…
33
votes
4 answers

Logging into text file or database?

When should I use database for logging and when text files? I see that web servers and web frameworks (that your app uses internally) usually (always?) log requests and errors into text files by default. But I see that people who develop their app…
Nakilon
  • 489
  • 1
  • 4
  • 13
33
votes
4 answers

What is the correct way to handle debug output in Java?

As my current Java projects grow bigger and bigger, I feel a likewise growing need to insert debug output in several points of my code. To enable or disable this feature appropriately, depending on the opening or closure of the test sessions, I…
Federico Zancan
  • 1,403
  • 2
  • 14
  • 19
31
votes
10 answers

Does logging inside a class violate the SRP?

I wrote a class that takes a Logger class as one of its arguments: class QueryHandler: def __init__(self, query: Query, logger: Logger) -> None: self.query = query self.logger = logger def run(self) -> None: try: …
25
votes
2 answers

Logging in JSON Effect on Performance

I see more and more articles about logging in JSON. You can also find one on NodeJS blog. Why does everyone like it so much? I can only see more operations getting involved: A couple new objects being created. Stringifying objects, which either…
Pijusn
  • 987
  • 1
  • 10
  • 16
1
2 3
17 18