The world's largest supply platform for sources of shortages and hard-to-find parts

Log4Net Stores logs

Published Time: 2022-08-20 17:17:47
In the development of upper computer, log recording is indispensable, we can do log analysis and error tracking through log recording.

Beginners will use TXT text writing to achieve log saving, but text writing is not thread safe, when there are multiple threads writing to the log, there will be some problems. Log4net library is. The next great open source logging component in.NET is a tool that helps developers export logging information to a variety of targets (consoles, files, databases, etc.). In this section, the open-source component Log4Net is used to store the text of ERROR information. In combination with SQLite database, log INFO information is stored in the database for subsequent query.


SQLite store


The advantage of storing log information in the database is that it is easy for users to query logs through the interface. The open source free database SQLite is used here. Other relational databases, such as SQLServer and mysql, have the same principle, and the specific steps are as follows:


Create databases and tables


Use SQLiteStudio software to create a database, named Log4NetSQLite, execute the following script to create a Log table:

BufferSize: When the number of log cache writes is set to 0, write to the database immediately as long as there is one


ConnectionString: SQLite points to the absolute path of the database file


Add an Info method to the LogHelper class like this:


More Products Hot Selling

MECT-110-01-M-D-RA1
Pluggable Connectors
MECT-110-01-M-D-RA1
20 Position SFP+ Receptacle Connector Solder Surface Mount, Right Angle
FG6943010R
Transistors - FETs, MOSFETs - Arrays
FG6943010R
FG6943010R Panasonic Electronic Components
TSHA4401
LED Emitters - Infrared, UV, Visible
TSHA4401
TSHA4401 Vishay Semiconductor Opto Division
MAX7456EUI-T
Audio Special Purpose
MAX7456EUI-T
MAX7456EUI+T Manufacturer Analog Devices Inc./Maxim Integrated Video IC Serial, SPI NTSC, PAL 28-TSSOP-EP Package
EPM7064SLI44-7N
Embedded - PLDs (Programmable Logic Device)
EPM7064SLI44-7N
EPM7064SLI44-7N Altera IC CPLD 64MC 7.5NS 44PLCC
APTGF75H120TG
Transistors - IGBTs - Modules
APTGF75H120TG
APTGF75H120TG Manufacturers Microchip Technology IGBT Modules Power Module - IGBT
R-785-0-0-5
PMIC - DC-DC Converter
R-785-0-0-5
R-785.0-0.5 Manufacturer Recom Power Linear Regulator Replacement DC DC Converter 1 Output 5V 500mA 6.5V - 32V Input
R570452000
Coaxial Switches
R570452000
R570452000 Coaxial Switches SPDT Ramses SMA 18GHz Latching Self-cut-off 12Vdc Diodes Pins Terminals
NTCALUG01T103G400A
Temperature Sensors - Thermostats - Solid State
NTCALUG01T103G400A
NTCALUG01T103G400A Temperature Sensors - Thermostats NTC LUG01T 10K 2% 3984K G26 40MM
AD8223ARMZ-R7
Audio Special Purpose
AD8223ARMZ-R7
Single-Supply, Low Cost Instrumentation Amplifier
M29W640GB70NA6E
Memory IC
M29W640GB70NA6E
Parallel NOR Flash Embedded Memory M29W640GH, M29W640GL M29W640GT, M29W640GB

Recommended Parts