# serilog-sinks-mysql **Repository Path**: luqingfei/serilog-sinks-mysql ## Basic Information - **Project Name**: serilog-sinks-mysql - **Description**: https://github.com/singbaX/serilog-sinks-mysql - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: dev - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-04-25 - **Last Updated**: 2024-04-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Serilog.Sinks.MySQL Serilog sink that writes to MySQL database. ## Getting started Install [Serilog.Sinks.MySQL](https://www.nuget.org/packages/Serilog.Sinks.MySQL) from NuGet ```PowerShell Install-Package Serilog.Sinks.MySQL ``` Configure logger by calling WriteTo.MySQL ```C# var logger = new LoggerConfiguration() .WriteTo.MySQL("server=127.0.0.1;uid=user;pwd=password;database=diagnostics;") .CreateLogger(); logger.Information("This informational message will be written to MySQL database"); ``` ## XML configuration To use the rolling file sink with the [Serilog.Settings.AppSettings](https://www.nuget.org/packages/Serilog.Settings.AppSettings) package, first install that package if you haven't already done so: ```PowerShell Install-Package Serilog.Settings.AppSettings ``` In your code, call `ReadFrom.AppSettings()` ```C# var logger = new LoggerConfiguration() .ReadFrom.AppSettings() .CreateLogger(); ``` In your application's App.config or Web.config file, specify the MySQL sink assembly and required **connectionString** under the `` node: ```XML ``` >Note: This sink version 4.1 has breaking changes. It expects an additional column `Template` of type Template `TEXT` in log table. It is recommended to add this column manually or delete existing table so that it can be recreated correctly. [![Build status](https://ci.appveyor.com/api/projects/status/tse5g3weca5nmky3?svg=true)](https://ci.appveyor.com/project/SaleemMirza/serilog-sinks-mysql) --- Many thanks to the [](https://www.jetbrains.com "JetBrains") for donating awesome suite of tools making this project possible.