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.

Filter by
Sorted by
Tagged with
3877votes
14answers
1.3mviews

grep a file, but show several surrounding lines?

I would like to grep for a string, but also show the preceding five lines and the following five lines as well as the matched line. How would I be able to do this?
user avatar
1420votes
16answers
1.0mviews

String formatting: % vs. .format vs. f-string literal

Python 2.6 introduced the str.format() method with a slightly different syntax from the existing % operator. Which is better and for what situations? Python 3.6 has now introduced another string ...
user avatar
  • 17.1k
1141votes
13answers
495kviews

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 | ...
user avatar
  • 17.2k
747votes
14answers
216kviews

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, ...
user avatar
733votes
12answers
1.0mviews

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 %(...
user avatar
  • 56.6k
697votes
20answers
456kviews

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?
user avatar
  • 13.1k
639votes
12answers
277kviews

How can I 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 ...
user avatar
  • 7,305
616votes
14answers
479kviews

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 ...
user avatar
612votes
16answers
243kviews

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? (...
user avatar
609votes
8answers
535kviews

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?
user avatar
  • 12.1k
592votes
10answers
544kviews

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 ...
user avatar
586votes
19answers
300kviews

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 ...
user avatar
  • 13.3k
570votes
8answers
112kviews

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 ...
user avatar
  • 9,089
530votes
6answers
354kviews

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 ...
user avatar
  • 21.8k
521votes
20answers
354kviews

heroku - 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 ...
user avatar
  • 5,305
521votes
10answers
566kviews

How to show the last queries executed on MySQL?

Is there any query/way to show the last queries executed on ALL servers?
user avatar
  • 33.6k
505votes
8answers
401kviews

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? ...
user avatar
  • 10.8k
451votes
21answers
463kviews

How to log SQL statements in Spring Boot?

I want to log SQL statements in a file. I have the following properties in application.properties spring.datasource.url=... spring.datasource.username=user spring.datasource.password=1234 spring....
user avatar
  • 19.3k
443votes
37answers
390kviews

How to do logging in React Native

How can I log a variable in React Native, like using console.log when developing for web?
user avatar
  • 15.2k
436votes
30answers
196kviews

How to remove all debug logging calls before building the release version of an Android app?

According to Google, I must "deactivate any calls to Log methods in the source code" before publishing my Android app to Google Play. Extract from section 3 of the publication checklist: Make sure ...
user avatar
431votes
38answers
240kviews

How can I color Python logging output?

Some time ago, I saw a Mono application with colored output, presumably because of its log system (because all the messages were standardized). Now, Python has the logging module, which lets you ...
user avatar
  • 6,491
425votes
12answers
374kviews

Where is the Docker daemon log?

Where is the Docker daemon log? Oddly cannot find an answer to this via man, StackOverflow or Docker Docs. Note I am not asking for the docker container STDOUT, but the daemon log for troubleshooting ...
user avatar
  • 4,371
424votes
12answers
495kviews

How to log PostgreSQL queries?

How to enable logging of all SQL executed by PostgreSQL 8.3? Edited (more info) I changed these lines : log_directory = 'pg_log' log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' ...
user avatar
  • 11.8k
423votes
10answers
224kviews

How to output git log with the first line only?

I am trying to customize the format for git log. I want all commits to be shown in one line. Each line should only show the first line of the commit message. I found out that git log --pretty=short ...
user avatar
  • 46.9k
416votes
12answers
170kviews

How do I disable log messages from the Requests library?

By default, the Requests python library writes log messages to the console, along the lines of: Starting new HTTP connection (1): example.com http://example.com:80 "GET / HTTP/1.1" 200 606 I'm ...
user avatar
  • 61.1k
401votes
5answers
77kviews

Why not use java.util.logging?

For the first time in my life I find myself in a position where I'm writing a Java API that will be open sourced. Hopefully to be included in many other projects. For logging I (and indeed the people ...
user avatar
  • 16.8k
399votes
7answers
196kviews

How to print the current Stack Trace in .NET without any exception?

I have a regular C# code. I have no exceptions. I want to programmatically log the current stack trace for debugging purpose. Example: public void executeMethod() { logStackTrace(); method();...
user avatar
  • 8,931
390votes
18answers
609kviews

Spring Boot: How can I set the logging level with application.properties?

This is very simple question, but I cannot find information. (Maybe my knowledge about Java frameworks is severely lacking) How can I set the logging level with application.properties? And logging ...
user avatar
  • 9,331
359votes
10answers
614kviews

IIS: Where can I find the IIS logs?

I'm trying to set up an application from a third party, which requires a supporting website hosted in my local IIS. I've created a website exactly as explained in their install guide, but am having ...
user avatar
  • 17.8k
357votes
10answers
243kviews

Most useful NLog configurations [closed]

What are the best or most useful configurations for logging with NLog? (These can be simple or complex, as long as they're useful.) I'm thinking of examples like automatically rolling over log files ...
user avatar
  • 15.8k
355votes
12answers
255kviews

Using logging in multiple modules

I have a small python project that has the following structure - Project -- pkg01 -- test01.py -- pkg02 -- test02.py -- logging.conf I plan to use the default logging module to print ...
user avatar
  • 7,532
333votes
8answers
411kviews

Log all queries in mysql

Is it possible for me to turn on audit logging on my mysql database? I basically want to monitor all queries for an hour, and dump the log to a file.
user avatar
323votes
10answers
173kviews

Logging best practices [closed]

I'd like to get stories on how people are handling tracing and logging in real applications. Here are some questions that might help to explain your answer. Frameworks What frameworks do you use? ...
user avatar
  • 31.7k
311votes
25answers
486kviews

Spring Boot - How to log all requests and responses with exceptions in single place?

I'm working on rest api with spring boot. I need to log all requests with input params (with methods, eg. GET, POST, etc), request path, query string, corresponding class method of this request, also ...
user avatar
  • 7,695
306votes
3answers
233kviews

How to log formatted message, object array, exception?

What is the correct approach to log both a populated message and a stack trace of the exception? logger.error( "\ncontext info one two three: {} {} {}\n", new Object[] {"1",...
user avatar
  • 3,061
290votes
3answers
458kviews

Good examples using java.util.logging [closed]

I want to use logs in my program. I heard about java.util.logging, but I don't know how to begin. Are there any examples of what can I do with logging? How would I use logging in my own program?
user avatar
289votes
15answers
460kviews

How to enable MySQL Query Log?

How do I enable the MySQL function that logs each SQL query statement received from clients and the time that query statement has submitted? Can I do that in phpmyadmin or NaviCat? How do I analyse ...
user avatar
289votes
23answers
191kviews

How should I log while using multiprocessing in Python?

Right now I have a central module in a framework that spawns multiple processes using the Python 2.6 multiprocessing module. Because it uses multiprocessing, there is module-level multiprocessing-...
user avatar
  • 66.4k
284votes
5answers
244kviews

Can I change the name of `nohup.out`?

When I run nohup some_command &, the output goes to nohup.out; man nohup says to look at info nohup which in turn says: If standard output is a terminal, the command's standard output is ...
user avatar
273votes
6answers
182kviews

How to Customize the time format for Python logging?

I am new to Python's logging package and plan to use it for my project. I would like to customize the time format to my taste. Here is a short code I copied from a tutorial: import logging # create ...
user avatar
  • 33.4k
272votes
5answers
156kviews

Logging levels - Logback - rule-of-thumb to assign log levels

I'm using logback in my current project. It offers six levels of logging: TRACE DEBUG INFO WARN ERROR OFF I'm looking for a rule of thumb to determine the log level for common activities. ...
user avatar
268votes
9answers
334kviews

How to log cron jobs?

I want to know how I can see exactly what the cron jobs are doing on each execution. Where are the log files located? Or can I send the output to my email? I have set the email address to send the log ...
user avatar
  • 6,633
262votes
11answers
77kviews

Should a "static final Logger" be declared in UPPER-CASE?

In Java, static final variables are constants and the convention is that they should be in upper-case. However, I have seen that most people declare loggers in lower-case which comes up as a violation ...
user avatar
  • 253k
258votes
31answers
285kviews

How to do a JUnit assert on a message in a logger

I have some code-under-test that calls on a Java logger to report its status. In the JUnit test code, I would like to verify that the correct log entry was made in this logger. Something along the ...
user avatar
  • 3,029
256votes
17answers
188kviews

What happened to console.log in IE8?

According to this post it was in the beta, but it's not in the release?
user avatar
  • 24.2k
249votes
28answers
302kviews

Spring RestTemplate - how to enable full debugging/logging of requests/responses?

I have been using the Spring RestTemplate for a while and I consistently hit a wall when I'am trying to debug it's requests and responses. I'm basically looking to see the same things as I see when I ...
user avatar
  • 2,907
248votes
28answers
145kviews

Why doesn't logcat show anything in my Android?

Why doesn't logcat show anything in my Android (while developing apps with Eclipse)? It just doesn't print anything. It's empty.
user avatar
  • 235k
247votes
6answers
526kviews

Retrieve last 100 lines logs

I need to retrieve last 100 lines of logs from the log file. I tried the sed command sed -n -e '100,$p' logfilename Please let me know how can I change this command to specifically retrieve the last ...
user avatar
  • 2,938
246votes
9answers
160kviews

redirect COPY of stdout to log file from within bash script itself

I know how to redirect stdout to a file: exec > foo.log echo test this will put the 'test' into the foo.log file. Now I want to redirect the output into the log file AND keep it on stdout i.e. ...
user avatar
241votes
18answers
204kviews

live output from subprocess command

I'm using a python script as a driver for a hydrodynamics code. When it comes time to run the simulation, I use subprocess.Popen to run the code, collect the output from stdout and stderr into a ...
user avatar

15 30 50 per page
1
2 3 4 5
770