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" />
Related
I have one site and 3 applications in 3 virtual folders and 3 app pools.
I use URL rewrite (redirect or rewrite doesn't matter) to catch some wrong urls and rewrite or redirect to appropriate application.
All 3 apps are asp.net MVC and use Forms Auth.
They must use sepparate app pools.
If I use rewrite I have an error that URL can't be served from same app pool, so rewriting doesn't work across app pools, that is a known issue.
If I use redirect there is a problem that before I can issue a redirect from URL rewrite FormsAuth sends redirect for login.
This is scenario where I am already logged in in app1, but I want to redirect from app2 and app2 has no session yet and it redirects me to login of app2 instead that I get URErewrite/redirect to URL in app1.
Can this be overridden ?
So that URL Rewrite redirect is not surpassed with FormsAuth redirect.
I tried to put RewriteModule in front of FormsAuthentication module in main applicationHost.config (C:\Windows\System32\inetsrv\Config) but it doesn't work :
<modules>
<add name="IsapiModule" lockItem="true" />
<add name="IsapiFilterModule" lockItem="true" />
<add name="HttpLoggingModule" lockItem="true" />
<add name="HttpCacheModule" lockItem="true" />
<add name="StaticCompressionModule" lockItem="true" />
<add name="DefaultDocumentModule" lockItem="true" />
<add name="DirectoryListingModule" lockItem="true" />
<add name="ProtocolSupportModule" lockItem="true" />
<add name="HttpRedirectionModule" lockItem="true" />
<add name="StaticFileModule" lockItem="true" />
<add name="AnonymousAuthenticationModule" lockItem="true" />
<add name="WindowsAuthenticationModule" lockItem="true" />
<add name="RequestFilteringModule" lockItem="true" />
<add name="CustomErrorModule" lockItem="true" />
<add name="FailedRequestsTracingModule" lockItem="true" />
<add name="ConfigurationValidationModule" lockItem="true" />
<add name="OutputCache" type="System.Web.Caching.OutputCacheModule" preCondition="managedHandler" />
<add name="RewriteModule" />
<add name="Session" type="System.Web.SessionState.SessionStateModule" preCondition="managedHandler" />
<add name="WindowsAuthentication" type="System.Web.Security.WindowsAuthenticationModule" preCondition="managedHandler" />
<add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule" preCondition="managedHandler" />
<add name="DefaultAuthentication" type="System.Web.Security.DefaultAuthenticationModule" preCondition="managedHandler" />
<add name="RoleManager" type="System.Web.Security.RoleManagerModule" preCondition="managedHandler" />
<add name="UrlAuthorization" type="System.Web.Security.UrlAuthorizationModule" preCondition="managedHandler" />
<add name="FileAuthorization" type="System.Web.Security.FileAuthorizationModule" preCondition="managedHandler" />
<add name="AnonymousIdentification" type="System.Web.Security.AnonymousIdentificationModule" preCondition="managedHandler" />
<add name="Profile" type="System.Web.Profile.ProfileModule" preCondition="managedHandler" />
<add name="UrlMappingsModule" type="System.Web.UrlMappingsModule" preCondition="managedHandler" />
<add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="managedHandler,runtimeVersionv4.0" />
<add name="ScriptModule-4.0" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" preCondition="managedHandler,runtimeVersionv4.0" />
<add name="ApplicationRequestRouting" />
</modules>
</system.webServer>
UPDATE ::::::::::::::::::
I didn't find out a way to overide FormsAuth so I went the ARR route.
I have 4 sites (no more one site and 3 apps/virtualFolders) :
*_ARR site listens to real ip and virtual host, it is empty , it only has URL rewrite rules, so it is guaranteed that URL rewrites are executed before everithing, the problem of Rewriting to another APP pool is solved by ARR reverse proxy, URL Rewrice at the end causes local reconnection ala reverse proxy, there aro no server farms configured in ARR, only one checkbox (enable proxy).
Other three sites keep 3 versions of app.
There is a file that keeps a record which version is the last installed.
There is a cookie issued for affinity to site/version of app.
All that is handled in custom URL revrite provider.
Cookies with this solution :
Cookie basicaly has the port writen inside. So URL rewrite sends the user to correct version.
And new logons go to newest version, allready logged in user stays at his current version, and finnaly it works as it needs to work.
All this because as I said before , objects in our Session can't be serialized.
And for existing loggins there is no performance hit in starting up site.
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.
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 am facing a problem while trying to use GZip .
I have used the below entries in my config files i.e., applicationHost.config and web.config
<httpCompression>
<staticTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="*/*" enabled="false" />
</staticTypes>
<dynamicTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="*/*" enabled="false" />
</dynamicTypes>
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" dynamicCompressionLevel="4" />
</httpCompression>
<urlCompression doDynamicCompression="true" doStaticCompression="true"/>
I have my application being deployed on IIS 7.5.
I have seen these suggestions over the net and I happen to hear that I would not need an exclusive stream code to be written. An entry to config file would suffice.
But still I get an error when my WCF service returns me a collection object with records over 1000. The object is a serializable object.
Please help me in this issue
I have the following section added to my web.config:
<system.webServer>
<caching>
<profiles>
<add extension=".html" policy="CacheUntilChange" kernelCachePolicy="DontCache" location="Client" />
<add extension=".htm" policy="CacheUntilChange" kernelCachePolicy="DontCache" location="Client" />
<add extension=".gif" policy="CacheUntilChange" kernelCachePolicy="DontCache" location="Client" />
<add extension=".js" policy="CacheUntilChange" kernelCachePolicy="DontCache" location="Client" />
<add extension=".css" policy="CacheUntilChange" kernelCachePolicy="DontCache" location="Client" />
<add extension=".jpg" policy="CacheUntilChange" kernelCachePolicy="DontCache" location="Client" />
</profiles>
</caching>
</system.webServer>
which was taken directly from here
but I am getting an error in my web.config, saying:
Unrecognized configuration section system.web/caching/profiles
also, I see this in visual studio:
The element caching has invalid child element 'profiles', List of possible expected: cache, outputcache, outputcacheSettings, sqlCacheDependency'
did something about this configuration change as I see alot of examples on the web with this exact configuration?
In your screenshot you have the caching under <system.web> and not <system.webServer> and since profiles is not a valid element under <caching> for <system.web> you will get that error.
What you show in code example is under <system.webServer>, what you show in your screenshot is under <system.web>, it needs to be under webServer for it to get the profiles option, under system.web like you had it offers all those options that the error you received was talking about, behaves differently depending on where you call it from