I am using InfluxDB.client in my .NET 8.0 worker application. When running the code using dotnet run, I do not get the logs below. When I compile it to a selfcontained application and run it using systemd on the controller it fills up the journalctl on the controller with these messages every time a datapoint is sent to the server:
Sep 04 02:52:12 compulab-imx8mp TSLogger[1138]: Flushing batches before shutdown.
Sep 04 02:52:12 compulab-imx8mp TSLogger[1138]: The data was successfully written to InfluxDB 2.
Sep 04 02:52:12 compulab-imx8mp TSLogger[1138]: The batch item: OnNext(RestSharp.RestResponse) was processed successfully.
Sep 04 02:52:12 compulab-imx8mp TSLogger[1138]: The WriteApi was disposed.
Sep 04 02:52:12 compulab-imx8mp TSLogger[1138]: The data was successfully written to InfluxDB 2.
Sep 04 02:52:12 compulab-imx8mp TSLogger[1138]: The batch item: OnNext(RestSharp.RestResponse) was processed successfully.
Sep 04 02:52:12 compulab-imx8mp TSLogger[1138]: The WriteApi was disposed.
Relevant InfluxDB Code:
string tokenInfluxDb = cabinetConfig.InfluxDb.Token;
string urlInfluxDb = cabinetConfig.InfluxDb.Url;
string org = cabinetConfig.InfluxDb.Org;
string bucket = cabinetConfig.InfluxDb.Bucket;
clientInfluxDb = new InfluxDBClient(urlInfluxDb, tokenInfluxDb);
var point = PointData
.Measurement(item.Cage)
.Field(item.MeasurementId, value)
.Tag("sn", item.SerialNumber)
.Timestamp(DateTime.UtcNow, WritePrecision.Ns);
LogToDb(point);
async void LogToDb(PointData point)
{
using (var writeApi = clientInfluxDb.GetWriteApi())
{
writeApi.WritePoint(point, bucket, org);
}
}
Worker.csproj:
<TargetFramework>net8.0</TargetFramework>
<PackageReference Include="InfluxDB.Client" Version="4.14.0" />
systemd service file:
[Unit]
Description=InfluxDBWorker
[Service]
ExecStartPre=/bin/sleep 30
WorkingDirectory=/home/usr/application/InfluxDBWorker
ExecStart=/home/usr/application/InfluxDBWorker/InfluxDBWorker
Restart=always
# Restart service after 60 seconds if the dotnet service crashes:
RestartSec=60
KillSignal=SIGINT
SyslogIdentifier=InfluxDBWorker
User=root
Environment=DOTNET_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
[Install]
WantedBy=multi-user.target
I have tried setting different logging parameters to warning in Environment variables and in appsettings.json, but it seems like these are coming from elsewhere.
I tried setting ForwardToConsole=no in journald.conf.
I have not been able to disable this. I found this: https://github.com/influxdata/influxdb-client-csharp/issues/560 , but I could make it work.