Using XmlLogFormatter with the RollingFlatFileTraceListener in Enterprise Library - enterprise-library

I'm trying to use the RollingFlatFileTraceListener to provide rolling logs in my app along side the XmlLogFormatter so that the logs are in an XML format, however the app no longer seems to be logging anything.
<listeners>
<clear />
<add name="Rolling Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
fileName="C:\Inetpub\logs\rolling.log" rollFileExistsBehavior="Increment" header="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" footer="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" formatter="Error Formatter"
rollSizeKB="12499" maxArchivedFiles="3200" traceOutputOptions="None" timeStampPattern="yyyy-MM-dd" rollInterval="Midnight" />
</listeners>
<formatters>
<clear />
<add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.XmlLogFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" template="Timestamp: {timestamp(local)}
Message: {message}
Category: {category}
Severity: {severity}
Title:{title}
Machine: {machine}
Extended Properties: {dictionary({key} - {value}
)}" name="Error Formatter" />
</formatters>
Since the application isn't hard faulting, I can't see any errors to diagnose, yet I know that I should see some trace logs by now.
Update:
Current progress is that I've been able to use the RollingFlatFileTraceListnerData with the TextFormatter, making use of the template to specify XML. The two items that don't work as of yet are
The file has no XML declaration
The file has no root element, instead it has many root elements
Any thoughts on how to tack that on to the start and end of the file?

The out of the box trace listeners do not support a file header or file footer concept. As you've seen, it basically just appends to the file. Even if you used the .NET Framework System.Diagnostics.XmlWriterTraceListener it only writes XML fragments and not well formed XML documents.
One way to achieve what you want would be to create a separate process that modifies the archived files to be well formed after they have been rolled. The downside of that approach is that the active log file is not well formed.
If that is a concern then you will probably have to create a custom trace listener to do what you want. Instead of simply appending to the log file you could overwrite the XML document's closing tag (e.g. ) with the latest LogEntry and the closing tag.
Another interesting approach from the article Efficient Techniques for Modifying Large XML Files is to create a well formed XML document that includes the document with XML fragments. E.g.
<?xml version="1.0"?>
<!DOCTYPE logfile [
<!ENTITY events
SYSTEM "XMLFile1.xml">
]>
<logfile>
&events;
</logfile>

Related

Can I get additional trace information from Liquid XML

I'm having problems starting Liquid XML Studio, is there any way to get additional debug information from it to help diagnose the problem?
If you are having an issue with the product crashing or hanging, it may be helpful to our support team if you can provide additional debugging information by turning on tracing to a log file as follows:
1 - Login as Administrator.
2 - Backup the file C:\Program Files\Liquid Technologies\Liquid XML 2016\XmlStudio14.exe.config.
Note: the path is the folder into which you installed Liquid XML.
3 - Edit the file C:\Program Files\Liquid Technologies\Liquid XML 2016\XmlStudio14.exe.config and ensure the section below is uncommented
<system.diagnostics>
<trace autoflush="true" indentsize="4">
<listeners>
<add name="myListener"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="C:\Temp\TraceOutput.log" />
<remove name="Default" />
</listeners>
</trace>
</system.diagnostics>
4 - Ensure the Path specified in the config file (C:\Temp\TraceOutput.log) exists on your PC (e.g. C:\Temp).
5 - Start Liquid XML Studio.
6 - You should see a file is created in the specified folder (e.g. C:\Temp\TraceOutput.log)
7 - Perform the task which is causing an issue, then close the application.
8 - Send the TraceOutput.log to Liquid Support.
9 - Undo the changes made to C:\Program Files\Liquid Technologies\Liquid XML 2016\XmlStudio14.exe.config

Function imports for entity framework with odp.net managed driver

I recently switched from ODP Unmanaged to ODP Managed (in conjunction with Entity Framework).
The Unmanaged drivers were working fine after adding the necessary information in the web.config section. I could add the stored procedures and generate the complex types using the Function Import - Get Column information (I'm trying to import a stored procedure with an OUT refcursor parameter).
After the switch the config section was updated to reflect the new format and everything works at runtime (so the format is correct).
However when I try to generate the complex types again (or add a new Function Import) I just get a System.notSupportedException Message: The specified type is not supported by this selector) Without any indication which type/selector it is (obviously)...
Google has turned up nothing and the thread on the Oracle Forums has gathered no response as well.
Versions:
ODP.Net (ODAC) : v12.1 (Production release; DLL v4.121.1.0)
EF v5
.NET v4.5
Config file (trimmed a bit):
<configSections>
<section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess"/>
</configSections>
<oracle.manageddataaccess.client>
<version number="*">
<edmMappings>
<edmMapping dataType="number">
<add name="bool" precision="1"/>
<add name="byte" precision="2" />
<add name="int16" precision="5" />
<add name="int32" precision="10" />
<add name="int64" precision="38" />
</edmMapping>
</edmMappings>
<implicitRefCursor>
<storedProcedure schema="ECOM" name="SHP_API_ORDERS.CREATE_ORDER">
<refCursor name="O_RS">
<bindInfo mode="Output"/>
<metadata columnOrdinal="0" columnName="COL1" nativeDataType="Number" providerType="Decimal" allowDBNull="false" numericPrecision="10" numericScale="0" />
<metadata columnOrdinal="1" columnName="COL2" nativeDataType="Date" providerType="Date" allowDBNull="true" />
<metadata columnOrdinal="2" columnName="COL3" nativeDataType="Varchar2" providerType="Varchar2" allowDBNull="false" columnSize="10" />
</refCursor>
</storedProcedure>
</implicitRefCursor>
</version>
</oracle.manageddataaccess.client>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
</entityFramework>
<system.data>
<DbProviderFactories>
<remove invariant="Oracle.ManagedDataAccess.Client" />
<add name="ODP.NET, Managed Driver"
invariant="Oracle.ManagedDataAccess.Client"
description="Oracle Data Provider for .NET, Managed Driver"
type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</DbProviderFactories>
</system.data>
The implicit ref cursor config file format is different between Unmanaged ODP.NET and Managed ODP.NET. That might be part of your problem.
To save yourself from pulling your hair out, install the latest Oracle Developer Tools for Visual Studio (ODT) and use the new feature that automatically generates this config:
1) Install ODT 12.1 if you haven't already
2) Find the stored procedure in server explorer, right click it and run it, and enter input parameters.
3) For the output ref cursor that represents the return value for your Entity Function, choose "Add to Config" checkbox.
4) Then select either "Show Config" (and then cut and paste) or "Add to Config".
Here is a screenshot of what I am talking about:
http://i.imgur.com/t1BfmUP.gif
If this doesn't fix the problem, play around with that boolean mapping. I am not 100% sure of this as of this writing, but I remember hearing that support for booleans is another difference between managed and unmanaged ODP.NET. I'm sure it's buried in the release notes or doc somewhere.
Christian Shay
Oracle
Two things you would want to try which might potentially solve the issue:
Ensure the case of the schema name, stored procedure name and the
column names in the config are the same as that in the Oracle.
Try mapping the native type to a more conformant provider type, like
the first column COL1 - map an int32 providerType to the
number(10,0) nativeDataType as enforced by your edmmapping, instead of
the Decimal that you currently have. And so forth for the other
columns (like remove the column lengths) until you do not see the error or get a different one.
I've got the same error and I think my problem is a providerType of DOUBLE or DECIMAL. But, I got one to work that has your 3 column types. Your problem is that a number(10,0) should be a providerType of "Int64".
Stored Procedure:
create or replace PROCEDURE "PROC_ESCC_FIELDS" (p_recordset OUT SYS_REFCURSOR)
AS
BEGIN
OPEN p_recordset FOR
SELECT COL1, COL2, COL3
FROM MyTable;
END PROC_ESCC_FIELDS;
This works and returns the cursor:
<oracle.manageddataaccess.client>
<version number="*">
<implicitRefCursor>
<storedProcedure schema="SERFIS" name="PROC_V_SERFIS_ESCC_FIELDS">
<refCursor name="P_RECORDSET">
<bindInfo mode="Output" />
<metadata columnOrdinal="0" columnName="COL1" providerType="Int64" allowDBNull="false" nativeDataType="Number" />
<metadata columnOrdinal="1" columnName="COL2" providerType="Date" allowDBNull="true" nativeDataType="Date" />
<metadata columnOrdinal="2" columnName="COL3" providerType="Varchar2" allowDBNull="false" nativeDataType="Varchar2" />
</refCursor>
</storedProcedure>
</implicitRefCursor>
</version>
</oracle.manageddataaccess.client>
Click here for a list of the providerType and nativeDataType, etc. ENUMS:

multiple applications single config file

I'm trying to write a service and configuration application. VB/C++ 2010 I've had a number of hits on google but they largely seem to be obsolete. What I have so far is a project with a single form app and a service app. The single form app has an "app.config" file and I have added a section:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings file="settings.config">
</appSettings>
</configuration>
In the Solution I have added a "settings.config" file and its contents is:
<?xml version="1.0" encoding="utf-8"?>
<appSettings>
<add key="Setting1" value="This is Setting 1 from settings.config" />
<add key="Setting2" value="This is Setting 2 from settings.config" />
<add key="ConnectionString" value="ConnectString from settings.confg" />
</appSettings>
I have added a reference to then C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\Profile\Client\System.Configuration.dll
library in both the forms app and the service app
In the very simple forms app i have the following code
Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
Dim s As String = _
System.Configuration.ConfigurationManager.AppSettings("ConnectionString")
TextBox1.Text = s
End Sub
It doesn't work! Now clearly I am missing something. Its probably very simple. But my limited understanding is that this is automatically configuered by the config files I have? MS in their usual helful fashion seem to only give samples for 2012 and net 4.5 or greater. I need this to work on a 2003 server (as well) so I'm limited to net 4.0
The problem here is that the line System.Configuration.ConfigurationManager.AppSettings("ConnectionString") is looking for the key ConnectionString in your application's app.config file.
The fact that you have included that file key in your app.config file doesn't magically tell the ConfigurationManager to load the settings from a different file. If that's what you want you will have to read the setting for the file key and then manually load the configuration from that file.
This has not changed since the early versions of .Net though so I'm not sure why you were conflicted by the examples.
Add reference on existing assembly in .Net section of your Add Reference Popup
But i suggest you to use connectionStrings section in your config file
<connectionStrings>
<add name="myConnectionString" connectionString="server=localhost;database=myDb;uid=myUser;password=myPass;" />
</connectionStrings>
string connStr = ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString;

How do I get the EntLib database settings to stay deleted?

I'm using EntLib 5.0 for logging and exception handling, but not for data access.
Everytime I delete the 'database settings' app block using the entlib designer, it re-adds itself after I rebuild the application. It wouldn't be a problem and I'd just leave it except that it creates LocalSqlServer and LocalMySqlServer instances automatically and throws "LocalMy[DB]Server (Connection String): Connection string is a required value" on the next build.
I've just deleted it before every other build, but that's obviously pretty annoying.
So again, how can I delete it such that it'll stay deleted?
You need to edit your machine.config.
This issue started for me, after I installed Wordpress/MySQL via Web Matrix.
It added this line into my .NET 2.0 machine.config file:
<add name="LocalMySqlServer" connectionString="" />
So all you need to do is open it up in a text editor and comment out that line!
In my case, the file was here:
c:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG\machine.config
And I commented out two providers, e.g.:
<!-- <add name="OraAspNetConString" connectionString=" " />
<add name="LocalMySqlServer" connectionString="" /> -->

Template settings for Entlib logger

I had to move to the entlib logger from log4net. I know what you're thinking? :)
Anyways, I am trying to change the default template for the logger to get rid of the useless info - like like priority etc.. But my logs still have it - all those value are either null or default (value-types) in the log entry that's created. Here's the template:
<add template="Timestamp: {timestamp}{tab}Category: {category}{tab}Severity: {severity}{newline}
Process Id: {processId}{tab}Thread Id: {win32ThreadId}{newline}
Message: {message}"
type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="Text Formatter" />
I am still getting Event ID, Titel, Machine, Priority and Process name. Any help would be appreciated.
Is there a way to name the old roll-over log files using an number instead of time-stamp and specify the max roll-over count - like in log4net?
In the config file (app.config) there is an element formatters. You can change this (preferable with the config tool). One of mine looks like this:
<add
template="{timestamp} {machine}:{processId}:{threadName}({win32ThreadId}) {message}"
type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="LogFileFormatter" />