Where are the SQL Server Management Studio log files stored? - ssms

I want to look at the log files for SQL Server Management Studio and I can't figure out where they are stored on the file system. Where are they?

Mine are at C:\Users\username\AppData\Local\Temp\SSMS:
How I found them
Looking in the app.config for my version of SSMS (located at C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\ManagementStudio\Ssms.exe.config), I found a section that adds a logger:
<!-- Enhanced logging to help troubleshoot password loss issues -->
<system.diagnostics>
<sources>
<source name="UserSettings" switchName="SourceSwitch" switchType="System.Diagnostics.SourceSwitch" >
<listeners>
<add name="logFile" type="Microsoft.SqlServer.Diagnostics.STrace.LogFileTraceListener,
Microsoft.SqlServer.Diagnostics.STrace, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"
logPath="%TEMP%\SSMS\" encrypt="false" >
</add>
</listeners>
</source>
</sources>
<!-- ... other config here ... -->
</system.diagnostics>
In my case, %TEMP% evaluates to C:\Users\username\AppData\Local\Temp.

Related

VS Community - VB - Unable to read to or write from app.config via Settings dialog

Recently I posted a couple of errors I was having, relating to app.config in a VB project. Andrew Morton kindly pointed me to an existing answer which resolved the first part of the issue, but I've since found that I still can't add/update variables in app.config via the Settings dialog in the project properties, nor can the Settings dialog read the app.config file.
The error message is:
an error occurred while reading the app.config file. the file might be corrupted
If I manually change the variable in app.config the program I'm coding still finds the old value as it's taking it from Settings.Designer.vb, and that's not getting updated when I change the variable in Settings as the platform isn't reading the app.config.
I've (again) run the app.config through an XML checker, all fine. I read one solution for this issue, which suggested the cause can be duplicate elements in the 'sectionGroup' area of app.config, but mine doesn't appear to have duplicate elements (app.config posted).
Steps I have tried are:
Removed and re-added the project from the solution.
Updated VS.
Repaired VS.
Deleted the app.config file and the variables from the Project Properties - System dialog, then added a new app.config and recreated the variables in the System dialog.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="system.diagnostics" type="System.Diagnostics.DiagnosticsConfigurationHandler"/>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System.Configuration.ConfigurationManager, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" >
<section name="Doghunter.My.MySettings" type="System.Configuration.ClientSettingsSection, System.Configuration.ConfigurationManager, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" requirePermission="false" />
</sectionGroup>
</configSections>
<system.diagnostics>
<sources>
<!-- This section defines the logging configuration for My.Application.Log -->
<source name="DefaultSource" switchName="DefaultSwitch">
<listeners>
<add name="FileLog"/>
<!-- Uncomment the below section to write to the Application Event Log -->
<!--<add name="EventLog"/>-->
</listeners>
</source>
</sources>
<switches>
<add name="DefaultSwitch" value="Information" />
</switches>
<sharedListeners>
<add name="FileLog"
type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
initializeData="FileLogWriter"/>
<!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="Doghunter"/>
</sharedListeners>
</system.diagnostics>
<applicationSettings>
<Doghunter.My.MySettings>
<setting name="TestKey" serializeAs="String">
<value>Henry</value>
</setting>
<setting name="NewKey" serializeAs="String">
<value>Moscow</value>
</setting>
</Doghunter.My.MySettings>
</applicationSettings>
</configuration>
Rebuilding the project as a Windows Forms Application (.Net Framework 4.7.2) resolved it.
Originally chose 'plain' Windows Forms Application, which used 5.0
No idea why this is the case, but now works so all good.

Why need projectname.exe.config to run exe file in vb.net

I have developed a vb.net application using visual studio 2010 and MS SQL Server 2014. I have used crystal reports for reporting purpose.
target framwork 4.0
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
using crystal reports as
Build Action = Embedded Resource
Copy to output directory = Do not copy
in code crystal report is accessed as
Dim cryRpt As New myReportName
cryRpt.SetDataSource(xdataset.Tables(0))
problem is when I run myproject.exe located in myProject\bin\Debug, it works fine both for forms and crystal reports.
but if myproject.exe is copied to any other location, it crashes on run, where dataset is assigned to report.
Now if I copy myproject.exe.config file at same location as of exe file, it runs successfully.
so why exe file needs myproject.exe.config to run if it using dataset for records.
do I need to deploy myproject.exe.config with my exe file too?
regards.
this is code inside my config file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.diagnostics>
<sources>
<!-- This section defines the logging configuration for My.Application.Log -->
<source name="DefaultSource" switchName="DefaultSwitch">
<listeners>
<add name="FileLog"/>
<!-- Uncomment the below section to write to the Application Event Log -->
<!--<add name="EventLog"/>-->
</listeners>
</source>
</sources>
<switches>
<add name="DefaultSwitch" value="Information" />
</switches>
<sharedListeners>
<add name="FileLog"
type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
initializeData="FileLogWriter"/>
<!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
<!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> -->
</sharedListeners>
</system.diagnostics>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
My.Settings uses the .exe.config file I think. Easiest is to open it and see what settings are stored inside. You can then change your code to store those settings elsewhere.

Getting 'The 'location' attribute is not allowed" in App.Config while saving log info to a text file

I want to record the user activity in the Application.Log file so that I can check what he/ she did before any error occurred or simply check if any wrong activity is done by the user. First, to get record the activity I read the article 'How to: Write Log Messages (Visual Basic)' from Microsoft's documentation website and changed the appropriate value according to my need. It was all good, I was getting the information successfully in the Debug Output but when I wanted to save this to a text file then I encountered a problem. I followed the instruction given in the article 'How to: Write Event Information to a Text File (Visual Basic)' from Microsoft's documentation website.
The code written on the website to save log information to a text file is:
<add name="FileLogListener"
type="Microsoft.VisualBasic.Logging.FileLogTraceListener,
Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a"
initializeData="FileLogListenerWriter"
location="Custom"
customlocation="c:\temp\" />
All code mentioned above seems fine and no error is shown except the two location and customlocation, which throws an error Message,
The 'location' attribute is not allowed.
The 'customlocation' attribute is not allowed.
I tried a lot but can't solve this error. I have found an interesting note on that documentation site. It says the following.
ⓘ Note
To set the value of a listener property, use an attribute that has the same name as the property, with all letters in the name lowercase. For example, the location and customlocation attributes set the values of the Location and CustomLocation properties.
But I was failed to solve the error even by reading information given in these websites.
Please help!
I suspect that you may not have your config file quite right. I followed a link from this page to here and copied the config example into my app. I then went back to the other page and modified my config file based on that. I then ran my app, which had the default name of 'ConsoleApp1', and I did indeed see the file 'ConsoleApp1.log' written to the specified folder with the appropriate information. Here's what my final config file looked like:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7" />
</startup>
<system.diagnostics>
<sources>
<source name="DefaultSource" switchName="DefaultSwitch">
<listeners>
<add name="FileLogListener"/>
</listeners>
</source>
</sources>
<switches>
<add name="DefaultSwitch" value="Information" />
</switches>
<sharedListeners>
<add name="FileLogListener"
type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
initializeData="FileLogListenerWriter"
location="Custom"
customlocation="D:\johnm\Documents\" />
</sharedListeners>
</system.diagnostics>
</configuration>
and here's my VB code:
Module Module1
Sub Main()
TracingTest(My.Computer.FileSystem.CombinePath(My.Computer.FileSystem.SpecialDirectories.MyDocuments, "LogFile.txt"))
Console.ReadLine()
End Sub
Public Sub TracingTest(ByVal fileName As String)
My.Application.Log.WriteEntry($"Entering TracingTest with argument '{fileName}'.")
' Code to trace goes here.
My.Application.Log.WriteEntry($"Exiting TracingTest with argument '{fileName}'.")
End Sub
End Module

How to publish an MVC 6 website in IIS with multiple apps in the src folder

When I try to publish an asp.net 5 website with multiple web apps in the 'src' folder. It works okay in klr but If I run it under IIS, I get this error:
Failed to resolve the following dependencies for target framework 'Asp.Net,Version=v5.0'
Here is a very basic simple project attached that you might want to run under IIS.
http://www.filedropper.com/iissampleapp
Update: updating my question as requested.
In the attached project, I just right click on "IISSampleApp" and click publish. Visual studio creates files on local file system, which I then try to run under IIS. After publish, both of the web apps reside under src folder as src\IISSampleApp and src\SubApp. The IISSampleApp is the main app that should run as website, and it just references a class DateClass from SubApp.
I have created this sample project to get the answer, my actual project have similar structure and I get the same error.
I have uploaded the Precompiled version of the project here: http://www.filedropper.com/precompilediissample
Below is my generated web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="kpm-package-path" value="..\approot\packages" />
<add key="bootstrapper-version" value="1.0.0-beta3" />
<add key="runtime-path" value="..\approot\packages" />
<add key="kre-version" value="1.0.0-beta3" />
<add key="kre-clr" value="clr" />
<add key="kre-app-base" value="..\approot\src\IISSampleApp" />
</appSettings>
</configuration>
edit the web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="kpm-package-path" value="..\approot\packages" />
<add key="bootstrapper-version" value="1.0.0-beta3" />
<add key="runtime-path" value="YOUR-RUNTIME-BASE-PATH\.k\runtimes" />
<add key="kre-version" value="1.0.0-beta3" />
<add key="kre-clr" value="clr" />
<add key="kre-app-base" value="..\approot\src\YOURPROJECT" />
</appSettings>
</configuration>
and set the security policy for \approotand \wwwroot
update: updating the answer after question's update
That just can't work like this because the kpm bundle command packages website as website and not as class library and you have 2 Startup class which is no good. If you want to share code between 2 website create a class library.

Precompile not working with Razor views in MVC 4

I'm trying to precompile razor views but during the build VS2010 throws errors such as "#ViewBag does not exist in the current context." The project builds and runs fine when views are not precompiled.
In order to turn on view compilation I set the following node in the project file:
<MvcBuildViews>true</MvcBuildViews>
The section below exists in the Views Web.config file.
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.Optimization"/>
<add namespace="System.Xml"/>
<add namespace="System.Xml.Linq"/>
</namespaces>
</pages>
</system.web.webPages.razor>
Any ideas why the project won't build?
Geeze, do I ever feel like an idiot. Turns out there were some cshtml files in a _temp folder that resided inside of the project folder. Even though the folder was excluded from the solution the compiler was picking up the files contained therein. Moving that _temp file out of the project folder fixed the issue.