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
4123
votes
13 answers

grep: show lines surrounding each match

How do I grep and show the preceding and following 5 lines surrounding each matched line?
Mark Harrison
  • 297,451
  • 125
  • 333
  • 465
1231
votes
13 answers

How to have 'git log' show filenames like 'svn log -v'

SVN's log has a "-v" mode that outputs filenames of files changed in each commit, like so: jes5199$ svn log -v ------------------------------------------------------------------------ r1 | jes5199 | 2007-01-03 14:39:41 -0800 (Wed, 03 Jan 2007) | 1…
jes5199
  • 18,324
  • 12
  • 36
  • 40
896
votes
15 answers

python exception message capturing

import ftplib import urllib2 import os import logging logger = logging.getLogger('ftpuploader') hdlr = logging.FileHandler('ftplog.log') formatter = logging.Formatter('%(asctime)s %(levelname)s…
Hellnar
  • 62,315
  • 79
  • 204
  • 279
870
votes
22 answers

When to use the different log levels

There are different ways to log messages, in order of fatality: FATAL ERROR WARN INFO DEBUG TRACE How do I decide when to use which? What's a good heuristic to use?
raoulsson
  • 14,978
  • 11
  • 44
  • 68
824
votes
17 answers

How to see normal print output created during pytest run?

Sometimes I want to just insert some print statements in my code, and see what gets printed out when I exercise it. My usual way to "exercise" it is with existing pytest tests. But when I run these, I don't seem able to see any standard output (at…
Des
  • 9,195
  • 4
  • 18
  • 21
763
votes
14 answers

Hide strange unwanted Xcode logs

When using the Xcode 8+ and creating a new blank project, the following logs appear when running the application: 2016-06-13 16:33:34.406093 TestiOS10[8209:100611] bundleid: com.appc.TestiOS10, enable_level: 0, persist_level: 0,…
Hans Knöchel
  • 11,422
  • 8
  • 28
  • 49
731
votes
17 answers

How do I log a Python error with debug information?

I am printing Python exception messages to a log file with logging.error: import logging try: 1/0 except ZeroDivisionError as e: logging.error(e) # ERROR:root:division by zero Is it possible to print more detailed information about the…
probably at the beach
  • 14,489
  • 16
  • 75
  • 116
726
votes
16 answers

The shortest possible output from git log containing author and date

How can I show a git log output with (at least) this information: * author * commit date * change I want it compressed to one line per log entry. What's the shortest possible format for that? (tried --format=oneline but that does not show the…
Jesper Rønn-Jensen
  • 106,591
  • 44
  • 118
  • 155
686
votes
11 answers

Making Python loggers output all messages to stdout in addition to log file

Is there a way to make Python logging using the logging module automatically output things to stdout in addition to the log file where they are supposed to go? For example, I'd like all calls to logger.warning, logger.critical, logger.error to go to…
user248237
657
votes
8 answers

Is it possible to run one logrotate check manually?

Is it possible to run one iteration of logrotate manually without scheduling it on some interval?
Vladimir
  • 12,753
  • 19
  • 62
  • 77
633
votes
18 answers

How can I find the method that called the current method?

When logging in C#, how can I learn the name of the method that called the current method? I know all about System.Reflection.MethodBase.GetCurrentMethod(), but I want to go one step beneath this in the stack trace. I've considered parsing the stack…
flipdoubt
  • 13,897
  • 15
  • 64
  • 96
627
votes
10 answers

logger configuration to log to file and print to stdout

I'm using Python's logging module to log some debug strings to a file which works pretty well. Now in addition, I'd like to use this module to also print the strings out to stdout. How do I do this? In order to log my strings to a file I use…
stdcerr
  • 13,725
  • 25
  • 71
  • 128
571
votes
8 answers

How to get ELMAH to work with ASP.NET MVC [HandleError] attribute?

I am trying to use ELMAH to log errors in my ASP.NET MVC application, however when I use the [HandleError] attribute on my controllers ELMAH doesn't log any errors when they occur. As I am guessing its because ELMAH only logs unhandled errors and…
dswatik
  • 9,129
  • 10
  • 38
  • 53
560
votes
6 answers

Swift: print() vs println() vs NSLog()

What's the difference between print, NSLog and println and when should I use each? For example, in Python if I wanted to print a dictionary, I'd just print myDict, but now I have 2 other options. How and when should I use each?
User
  • 23,729
  • 38
  • 124
  • 207
555
votes
22 answers

How to see all the logs

I have a small app on heroku. Whenever I want to see the logs I go to the command line and do heroku logs That only shows me about 100 lines. Is there not a way to see complete logs for our application on heroku?
josh
  • 5,645
  • 3
  • 17
  • 7
1
2 3
99 100