Serilog UdpSysLog Missing Logs Serilog.Sinks.SyslogMessages - serilog

Update: Not a serilog issue. Tried TCP and the problem persisted. Turned out the log server was maxing out CPU so the logs were being lost. This problem didn't appear in log4net as it is blocking which limited the rate at which logs were sent. Solution is to up the spec of log server.
Recently started to use Serilog UdpSysLog for logging from .Net6.0 Console/Web Applications.
We noticed that sometimes there logs are missing. If we send a burst of logs for some reason there would be a random amount missing each time.
An example of a large burst would be if we were processing a file and there are difference to values. Each difference would be its own log so we could be sending up to 4000 logs.
While the logs are missing when using UdpSysLog they work fine when writing the file locally.
We swapped out serilog for log4net and could not reproduce the behaviour.
csproj
<PackageReference Include="Serilog" Version="2.11.0" />
<PackageReference Include="Serilog.Sinks.SyslogMessages" Version="2.0.6" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.2.0" />
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.2.0-dev-00752" />
<PackageReference Include="Serilog.AspNetCore" Version="6.0.0-dev-00265" />
appsettings.json
"Serilog": {
"WriteTo": [
{
"Name": "File",
"Args": {
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff}||{Level:u3}||{Product}||{Application}||{EnvironmentName}||{MachineName}||{ThreadId}||{CorrelationId}||{SourceContext}||{Message}{Exception}{NewLine}",
"path": "d:/loggingapp-.txt",
"retainedFileCountLimit": 7,
"rollingInterval": "Day"
}
},
{
"Name": "UdpSyslog",
"Args": {
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff}||{Level:u3}||{Product}||{Application}||{EnvironmentName}||{MachineName}||{ThreadId}||{CorrelationId}||{SourceContext}||{Message}{Exception}{NewLine}",
"host": "hostname",
"port": 514
}
}
]
}
Project.cs (Serilog setup)
var _builder = new ConfigurationBuilder();
_builder.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddEnvironmentVariables();
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
.MinimumLevel.Override("Microsoft.Hosting.Lifetime", LogEventLevel.Information)
.MinimumLevel.Override("Microsoft.AspNetCore", LogEventLevel.Warning)
.Filter.ByExcluding(Matching.WithProperty("RequestPath", "/healthz"))
.Enrich.WithProperty("Application", "Serilog")
.Enrich.WithProperty("Product", "LoggingTestApp")
.Enrich.WithEnvironmentName()
.Enrich.WithMachineName()
.Enrich.WithThreadId()
.Enrich.FromLogContext()
.ReadFrom.Configuration(_builder.Build())
.CreateLogger();
var _host = Host.CreateDefaultBuilder()
.ConfigureServices((context, services) => {
services.AddTransient<LoggingTestApp.IWorkflow, LoggingTestApp.Workflow>();
})
.UseSerilog()
.Build();

Related

Electron app not launching at windows startup

I am using electron app.setLoginItemSettings(settings) to enable my application to autostart at login. This is how I am implementing it:
const executable_path = process.execPath;
const exeName = path.basename(process.execPath);
...
const createWindow = () => {
...
ipcMain.on('close-me', (evt, arg) => {
var boot = settings.get("startatboot");
if (boot) {
app.setLoginItemSettings({
openAtLogin: true,
path: executable_path,
name: exeName,
args: [
'--processStart', `"${exeName}"`,
'--process-start-args'
]
})
} else {
app.setLoginItemSettings({
openAtLogin: false,
openAsHidden: false
});
}
app.quit()
});
...
};
And this result in the following inside the register (Computer\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run)
Test Autorun.exe for name
C:\Program Files\Test Autorun\Test Autorun.exe --processStart "Test Autorun.exe" --process-start-args for data
Now inside my package.json file I defined the following:
{
"name": "apptest",
"productName": "Test Autorun",
"version": "1.0.0",
"description": "Test Autorun",
"main": "src/index.js",
"scripts": {
"start": "electron-forge start",
"package": "electron-forge package",
"make": "electron-forge make",
"publish": "electron-forge publish",
"lint": "echo \"No linting configured\"",
"build-installer": "electron-builder"
},
"build": {
"appId": "apptest",
...
Now my problem is that the application is not running on start and I have no idea why this is happening, I tried changing a lot of the values to end up with this register content. All the attempts before were showing as different programs inside windows startup settings.
I have got to fill what I think is correct data inside the registers but there is something I am missing but I have no idea what it is. Any help would go a long way, thanks.
EDIT:
When I launch the app normally it always asks the user to allow the app with unknown publisher to make changes to the device. I don't know if that is why the app is not running on start or if the app would run showing the same message awaiting user approval.
EDIT2:
it is adding the register inside the HKEY_CURRENT_USER and not the HKEY_LOCAL_MACHINE
As I suspected, it was related to the unknown publisher popup; so, when I edited the registry entry related to UAC by using the following command line code shown below, the application started on boot.
%windir%\System32\reg.exe ADD HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 0 /f
Source.

Elasticsearch docker slow log file location settings

I am having difficulties to write slow logs for elasticsearch into docker image.
Elasticsearch docker settings
"HostConfig": { "Binds": [ "/mnt/mydisk/data:/usr/share/elasticsearch/data", "/mnt/mydisk/logs:/usr/share/elasticsearch/logs" ],
I changed elasticsearch index settings like below;
{
"index.search": {
"slowlog": {
"level": "info",
"threshold": {
"fetch": {
"warn": "2s",
"trace": "200ms",
"debug": "500ms",
"info": "800ms"
},
"query": {
"warn": "10s",
"trace": "500ms",
"debug": "2s",
"info": "5s"
}
}}}}
I can only see gc.logs in "/mnt/mydisk/logs" path, and there is no "/usr/share/elasticsearch/logs" folder or path.
How can I save slow logs into /mnt/mydisk/logs ?
BTW I can see slow logs via "docker logs elasticsearch" command, but I cannot find where its saved or change the path.
You are looking for this properties file: log4j2.properties. If you are using the official elastisearch image, the default setting is to log everything on stdout (i.e. docker logs )
Read more here.

Dialogflow or Firebase slow Execution

My dialogflow project has encountered the following error message that I have been unable to resolve. Has anyone encountered such an issue and aware of how to resolve this?
dialogflowFirebaseFulfillment
Warning, estimating Firebase
Config based on GCLOUD_PROJECT.
Initializing firebase-admin may
fail
I am thinking that there may be an issue with my package.json file:
{
"name": "dialogflowFirebaseFulfillment",
"description": "This is the default fulfillment for a Dialogflow agents using Cloud Functions for Firebase",
"version": "0.0.1",
"private": true,
"license": "Apache Version 2.0",
"author": "Google Inc.",
"engines": {
"node": "8"
},
"scripts": {
"start": "firebase serve --only functions:dialogflowFirebaseFulfillment",
"deploy": "firebase deploy --only functions:dialogflowFirebaseFulfillment"
},
"dependencies": {
"actions-on-google": "^2.2.0",
"firebase-admin": "^8.9.0",
"firebase-functions": "^3.2.0",
"dialogflow": "^0.6.0",
"dialogflow-fulfillment": "^0.6.1"
}
}
The warning message is only that - a warning. It does not mean there is a problem.
If you are not using firebase-admin calls, then you have nothing to worry about.
If you are using firebase-admin, then you just need to be sure that the environment is referencing the project you expect.
Update
The "slow execution" is likely due to the Cloud Function cold starting - the environment had been shut down or otherwise wasn't running, so it needs to initialize and setup the environment. On subsequent calls, within a reasonable time, it should already be running and you won't experience the slowdown.

ASP.NET Core 3.1 app on IIS Express: "This site can't be reached"

I'm working on an ASP.NET Core application that I have upgraded from v2.2 to v3.1.
When I start the application using IIS Express without SSL enabled, I get this error in Google Chrome:
This site can't be reached. localhost refused to connect.
When I enable SSL, I get this error instead:
This localhost page can't be found. No web page was found for the web address: https://localhost:44367.
I have have an IIS website configured to the directory where my application sits. In the project settings, I can set the 'Launch' setting to 'IIS', but when I do this I also get the same error.
Screenshot of my web project settings: .
When I create a new blank ASP.NET Core 3.1 web project and run it with the same settings on IIS Express, it runs fine.
Based on suggestions elsewhere, I have tried the following:
Cleaning and rebuilding
Deleting the .vs folder in the web project
Changing the port number (currently it is localhost:54236).
Enabling/disabling SSL
Restarting my machine
Loading up a fresh copy of my solution from Git on a separate working directory and trying to run it.
I'm at a loss.
Here is my launchSettings.json file:
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iis": {
"applicationUrl": "http://myapplication.debug",
"sslPort": 0
},
"iisExpress": {
"applicationUrl": "http://localhost:54236",
"sslPort": 44367
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Web": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
}
}
}
When comparing with the launchSettings.json file of a fresh project I can't see any notable difference. Is there anything else that would cause this failure?
I should note that I did change the port number - it was initially at port number 50192, but when I attempt to run the website to that address (http://localhost:50192) it gives me a different error:
It appears I was missing something in my Program.cs when upgrading from aspnetcore 2.2 to 3.1.
Until now I had this:
return WebHost.CreateDefaultBuilder(args)
.ConfigureServices(services => services.AddAutofac())
.UseStartup<Startup>();
On looking at a fresh v3.1 project, it had something like this instead:
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});

Failed Login Session in Twitter Connect Plugin for Ionic 3

I am trying to use Twitter Connect plugin with firebase for my Ionic 3 application. It was working perfect but now it is throwing Failed Login Session error in the console.
In package.json:
"dependencies": {
"#ionic-native/twitter-connect": "^4.19.0",
"twitter-connect-plugin": "git+https://github.com/chroa/twitter-connect-plugin.git",
},
"cordova": {
"plugins": {
"cordova-plugin-whitelist": {},
"twitter-connect-plugin": {
"FABRIC_KEY": "********************",
"TWITTER_KEY": "****************",
"TWITTER_SECRET": "******************"
}
}
}
In config.xml:
<plugin name="twitter-connect-plugin" spec="https://github.com/chroa/twitter-connect-plugin">
<variable name="FABRIC_KEY" value="***********" />
<variable name="TWITTER_KEY" value="***********" />
<variable name="TWITTER_SECRET" value="*************" />
</plugin>
I have checked all the keys and they are all correct. Can anyone point me what is the problem here?

Resources