I am trying to wire up my sinks and it seems for my rolling file sink my debug messages are not being logged (only info and above). Is my configuration wrong?
<!-- Serilog Configuration -->
<add key="serilog:using:Email" value="Serilog.Sinks.Email" />
<!-- Configure Serilog Email Sink -->
<add key="serilog:write-to:Email" />
<add key="serilog:write-to:Email.mailServer" value="***" />
<add key="serilog:write-to:Email.toEmail" value="***" />
<add key="serilog:write-to:Email.fromEmail" value="***" />
<add key="serilog:write-to:Email.mailSubject" value="Comply360 Portal Endpoint (DEV)" />
<add key="serilog:write-to:Email.restrictedToMinimumLevel" value="Warning" />
<add key="serilog:write-to:Email.outputTemplate" value="{Timestamp:HH:mm:ss} [{Level}] [{SourceContext}] [{CorrelationId}] {Message}{NewLine}{Exception}" />
<!-- Configure Serilog RollingFile Sink -->
<add key="serilog:write-to:RollingFile" />
<add key="serilog:write-to:RollingFile.restrictedToMinimumLevel" value="Debug" />
<add key="serilog:write-to:RollingFile.pathFormat" value="C:\Logs\comply360-portal-{Date}.txt" />
<add key="serilog:write-to:RollingFile.outputTemplate" value="{Timestamp:HH:mm:ss} [{Level}] [{SourceContext}] [{CorrelationId}] {Message}{NewLine}{Exception}" />
There is nothing "wrong" with your RollingFile sink config per se - it will only log messages with log level Debug or above (i.e. it will not log Verbose messages) as you intended.
However, the minimum log level for Serilog in general is Information, so it doesn't even send to your sink.
You need to change Serilog's default minimum level to at least Debug, in your case:
<add key="serilog:minimum-level" value="Debug" />
Your final config should look like this:
<add key="serilog:minimum-level" value="Debug" />
<add key="serilog:write-to:RollingFile" />
<add key="serilog:write-to:RollingFile.restrictedToMinimumLevel" value="Debug" />
<add key="serilog:write-to:RollingFile.pathFormat" value="C:\Logs\log-portal-{Date}.txt" />
<add key="serilog:write-to:RollingFile.outputTemplate" value="{Timestamp:HH:mm:ss} [{Level}] [{SourceContext}] [{CorrelationId}] {Message}{NewLine}{Exception}" />
Of course, if you later decide to add any sink that logs Verbose messages and above, you'll need to change the minimum-level to Verbose too.
i.e. serilog:minimum-level should always be the lowest level from all of your sinks.
Related
Using IIS10, ASP NET MVC 5
I have enabled dynamic and static compression in IIS and installed both features from Server Maanger. I added the below to my web.config:
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" staticCompressionLevel="9" />
<dynamicTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="application/json" enabled="true" />
<add mimeType="*/*" enabled="false" />
</dynamicTypes>
<staticTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="application/atom+xml" enabled="true" />
<add mimeType="application/xaml+xml" enabled="true" />
<add mimeType="*/*" enabled="false" />
</staticTypes>
</httpCompression>
<urlCompression doStaticCompression="true" doDynamicCompression="true" />
The css files appear to be served in as gzip compressed and the Response header contains:
content-encoding:gzip
However, when rendered on the browser the css file is not being registering (ie non of the styles are being applied).
Is there a step I have missed?
Ensure that the Dynamic content Compression feature and Static Content Compression are installed.
I've created an application that I want to get logging to Slack for a particular purpose. I've already confirmed that it is working logging to a RollingFile and to Seq. I've added in serilog.sinks.slackclient and the application runs, and logs, but nothing shows up in my Slack channel.
Can someone verify whether there is an issue with my config?
from app.config (obviously xxx, yyy, zzz are substituded for key values.):
<add key="serilog:minimum-level" value="Debug" />
<!--<add key="serilog:using:RollingFile" value="Serilog.Sinks.RollingFile" />-->
<add key="serilog:using:Slack" value="Serilog.Sinks.Slack" />
<add key="serilog:write-to:Slack" value="https://hooks.slack.com/services/xxx/yyy/zzz" />
<add key="serilog:write-to:Seq.serverUrl" value="http://localhost:5341/" />
<add key="serilog:write-to:RollingFile.pathFormat" value="C:\Logs\Serilog\Test-{Date}.txt" />
<add key="serilog:write-to:RollingFile.retainedFileCountLimit" value="10" />
The parameter name webhookUrl is missing out of the write-to directive:
<add key="serilog:write-to:Slack.webhookUrl"
value="https://hooks.slack.com/services/xxx/yyy/zzz" />
I'm trying to connect to Azure media storage to upload files but I get the error every time I try to upload a file.
The error arises in the following section of the code:
var container = CloudStorageAccount.Parse(
ConfigurationManager.AppSettings["StorageConnectionString"]).CreateCloudBlobClient()
.GetContainerReference(ConfigurationManager.AppSettings["StorageContainerReference"]);
The application settings is as follows:
<appSettings>
<add key="webpages:Version" value="2.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="PreserveLoginUrl" value="true" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="StorageConnectionString" value="DefaultEndpointsProtocol=https;AccountName=mediasvczfpr6c9dg9jx2;AccountKey=+DlbXTjZG7bni9LOKaYOxqsxBxXVmzh7BpPzWByBi/Csl9XZ+VRcqMbZxuwcbDIg88o73+6M9ByVLwsHNNyLKQ==" />
<add key="CloudStorageContainerReference" value="temporary-media" />
<add key="StorageAccountKey" value ="+DlbXTjZG7bni9LOKaYOxqsxBxXVmzh7BpPzWByBi/Csl9XZ+VRcqMbZxuwcbDIg88o73+6M9ByVLwsHNNyLKQ==" />
<add key="StorageAccountName" value="mediasvczfpr6c9dg9jx2" />
<add key="MediaAccountName" value="azurevideoportal" />
<add key="MediaAccountKey" value="T2yMBqN0mk2O//cX+5RMYhqWOS3ekd0RJ3bLtTO5TgI=" />
</appSettings>
I fail to see why it won't connect to my azure storage since I'm using the same connection for a different project where it works fine.
The container variable is returned a null value so the error says:
Additional information: Value cannot be null.
This is just a simple variable naming error :)
In your line of code that's causing the exception, you are referencing the variable StorageContainerReference from your Web.config file. However, in your Web.config file, the variable is named CloudStorageContainerReference.
Try this instead, and it should help:
<appSettings>
<add key="webpages:Version" value="2.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="PreserveLoginUrl" value="true" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="StorageConnectionString" value="DefaultEndpointsProtocol=https;AccountName=mediasvczfpr6c9dg9jx2;AccountKey=+DlbXTjZG7bni9LOKaYOxqsxBxXVmzh7BpPzWByBi/Csl9XZ+VRcqMbZxuwcbDIg88o73+6M9ByVLwsHNNyLKQ==" />
<add key="StorageContainerReference" value="temporary-media" />
<add key="StorageAccountKey" value ="+DlbXTjZG7bni9LOKaYOxqsxBxXVmzh7BpPzWByBi/Csl9XZ+VRcqMbZxuwcbDIg88o73+6M9ByVLwsHNNyLKQ==" />
<add key="StorageAccountName" value="mediasvczfpr6c9dg9jx2" />
<add key="MediaAccountName" value="azurevideoportal" />
<add key="MediaAccountKey" value="T2yMBqN0mk2O//cX+5RMYhqWOS3ekd0RJ3bLtTO5TgI=" />
</appSettings>
From this line in your code
var container = CloudStorageAccount.Parse(
ConfigurationManager.AppSettings["StorageConnectionString"]).CreateCloudBlobClient()
.GetContainerReference(ConfigurationManager.AppSettings["StorageContainerReference"]);
I dont see anything in your AppSettings called StorageContainerReference. From the Azure docs themselves I see something like this as being the right way
Link to Azure Docs
// Retrieve storage account from connection string.
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
// Create the blob client.
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
// Retrieve a reference to a container.
CloudBlobContainer container = blobClient.GetContainerReference("ContainerName");
From your example could be because theres no settings by the name given or could be a fult in the StorageConnectionString setting
I have an environmental problem somewhere in OWIN and I want to get some information about what is happening. I have read that I can enable tracing but can't find much information on how to do it.
I have added the following to my web.config but no joy. Is this possible?
<!-- 1. Enable the switch here. Without this, you get nothing. By default, Katana has "new SourceSwitch("Microsoft.Owin")" at the root level. -->
<switches>
<add name="Microsoft.Owin" value="Verbose" />
</switches>
<!-- 2. Add your shared listeners. -->
<trace autoflush="true" />
<sharedListeners>
<add name="file" type="System.Diagnostics.TextWriterTraceListener" initializeData="C:\traces\Microsoft.OWIN.trace.log" />
<add name="console" type="System.Diagnostics.ConsoleTraceListener" />
</sharedListeners>
<sources>
<!-- "Microsoft.Owin" is the SourceSwitch name katana is using at the rootlevel. By enabling this, we are enabling all sub level traces by the components (if we don't change the default trace settings). -->
<source name="Microsoft.Owin">
<listeners>
<add name="file" />
<add name="console" />
</listeners>
</source>
</sources>
Not 100% sure that this will solve your issue, but we got it working with following config. Slight difference in the following line:
<source name="Microsoft.Owin" switchName="Microsoft.Owin" switchType="System.Diagnostics.SourceSwitch">
Notice that the <source> tag includes a switchName (and switchType) attribute which is missing from your example. I think that this instruction links the TraceSource with the Switch and makes the entire work.
In our case, we use trace listeners for Azure Web sites (and web jobs).
<system.diagnostics>
<sharedListeners>
<add name="AzureTableTraceListener" type="Microsoft.WindowsAzure.WebSites.Diagnostics.AzureTableTraceListener, Microsoft.WindowsAzure.WebSites.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add name="AzureBlobTraceListener" type="Microsoft.WindowsAzure.WebSites.Diagnostics.AzureBlobTraceListener, Microsoft.WindowsAzure.WebSites.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add name="AzureDriveTraceListener" type="Microsoft.WindowsAzure.WebSites.Diagnostics.AzureDriveTraceListener, Microsoft.WindowsAzure.WebSites.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</sharedListeners>
<sources>
<source name="Microsoft.Owin" switchName="Microsoft.Owin" switchType="System.Diagnostics.SourceSwitch">
<listeners>
<add name="AzureTableTraceListener"/>
<add name="AzureDriveTraceListener"/>
</listeners>
</source>
</sources>
<switches>
<add name="Microsoft.Owin" value="All" />
</switches>
<trace autoflush="true" indentsize="4" />
</system.diagnostics>
I've add all scripts from my site into very big bundle (about 700kb). And now I want IIS to gzip it, but i can't.
I've tried everything I've found here and over the web, but nothing helps. Static *.js files age gzipped, but complete bundle not.
Is there any solution ?
Check the dynamic compression in IIS. It have to be enabled for both IIS and your website. You also must have a valid config in the applicationHost.config too.
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
<dynamicTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="application/json" enabled="true" />
<add mimeType="*/*" enabled="false" />
</dynamicTypes>
<staticTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="application/atom+xml" enabled="true" />
<add mimeType="application/xaml+xml" enabled="true" />
<add mimeType="*/*" enabled="false" />
</staticTypes>
</httpCompression>
Important Note : the content type of Bundling response is text/javascript, so check your config for this type.