Writing a Log file in C/C++

The standard method of logging (in my experience) is to use either the stdout or stderr streams. In C++ to use these you would need to include iostream, and use as below: #include <iostream> int main(int argc, char* argv[]) { using std::cout; using std::cerr; using std::endl; cout << “Output message” << endl; cerr << “Error … Read more

Rails console is not outputting SQL Statements to my Development Log

the rails console never writes to the log file, but you can achieve it quite easily, for example, if you execute following after starting the rails console ActiveRecord::Base.logger = Logger.new STDOUT rails will log all SQL statements to stdout, thus display them in your terminal. and since Logger.new accepts any stream as first argument, you … Read more

How to view docker logs from vscode remote container?

I’m not using remote containers, just local once, so not sure if this applies but for locally running containers, you can go to the “Docker” tab (you need to install the official Microsoft Docker VS Code Plugin) where you can see your running containers. Just right-click on the container you want to see the logs … Read more

In log4j 1.2 to log4j 2 migration, what to do with the DailyRollingFileAppender class?

You are looking for the RollingFile appender <RollingFile name=”DAILY_LOG” fileName=”log/daily.log” filePattern=”log/%d{ddMMyyyy}_daily.log” > <PatternLayout pattern=”%d [%7r] %5p – %c – %m%n”/> <Policies> <TimeBasedTriggeringPolicy interval=”1″/> </Policies> </RollingFile> The previous sample rolls over by day, the interval being 1 unit which is determined by the smallest unit of the date lookup in the file pattern. In other words … Read more

Flask logging not working at all

Your (debug) logging messages are getting suppressed by Flask as you’re not running in debug mode. If you set the following flag to True, your code will work. app.run(debug=True) The messages will now appear as expected. BennyE$ python3 stackoverflow.py 2015-03-08 12:04:04,650 ERROR: firs test message… [in stackoverflow.py:31] * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit) … Read more

How to use Serilog in .NET Core Console app

I’m not sure about builder.SetMinimumLevel (it doesn’t use the Serilog enum). We set the logger level when creating the LoggerConfiguration object. Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .WriteTo.Console(restrictedToMinimumLevel: LogEventLevel.Debug) // restricted… is Optional (…) .CreateLogger(); BTW. It’s worth pointing out the following section from Configuration Basics Logger vs. sink minimums – it is important to realize … Read more

Logging within Program.cs

Accidentally stumbled upon the answer after googling a bit more. using System; using Microsoft.Extensions.Logging; namespace ConsoleApplication { public class Program { public static void Main(string[] args) { var logFactory = new LoggerFactory() .AddConsole(LogLevel.Debug) .AddDebug(); var logger = logFactory.CreateLogger<Type>(); logger.LogInformation(“this is debug log”); } } } Kudos to https://askguanyu.wordpress.com/2016/09/26/net-core-101-e06-net-core-logging/