Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid xsi:Type EntityFramework #1

Open
RiderOfTheli opened this issue Aug 13, 2015 · 3 comments
Open

Invalid xsi:Type EntityFramework #1

RiderOfTheli opened this issue Aug 13, 2015 · 3 comments

Comments

@RiderOfTheli
Copy link

Hi,

I was trying to adapt your solution for my application. I've add to my app.Config:

  <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" autoReload="true" throwExceptions="false">
<extensions>
  <add assembly="NLog.EntityFramework" />
</extensions>
<targets async="true">
  <target name="db" xsi:type="EntityFramework" connectionStringName="TimerConnection" commandText="INSERT INTO [dbo].[tbl_TT_Error_Log] ([CallSite], [CreateDate], [Exception], [ErrorLevel], [Logger], [MachineName], [Message], [StackTrace], [Thread], [Username]) VALUES (@CallSite, @Date, @Exception, @Level, @Logger, @MachineName, @Message, @StackTrace, @Thread, @Username);">
    <parameter name="@CallSite" layout="${callsite:filename=true}" />
    <parameter name="@Date" layout="${longdate}" />
    <parameter name="@Exception" layout="${exception}" />
    <parameter name="@Level" layout="${level}" />
    <parameter name="@Logger" layout="${logger}" />
    <parameter name="@MachineName" layout="${machinename}" />
    <parameter name="@Message" layout="${message}" />
    <parameter name="@StackTrace" layout="${stacktrace}" />
    <parameter name="@Thread" layout="${threadid}" />
    <parameter name="@Username" layout="${windows-identity:domain=true}" />
  </target>
</targets>
<rules>
  <logger name="*" minlevel="Trace" writeTo="db" />
  <logger name="*" minlevel="Error" writeTo="db" />
  <logger name="*" minlevel="Debug" writeTo="db" />
</rules>

but what I get is: This is an invalid xsi:type 'http://www.nlog project.org/schemas/NLog.xsd:EntityFramework'.

I don't know - am I missing something?

Thank you for any suggestion.

@Misiu
Copy link

Misiu commented Sep 19, 2016

@RiderOfTheli EntityFramework is custom target, so official xsd shows error. Maybe Entity Framework will be officially supported, then You won't get that error.

@304NotModified
Copy link

If someone knows how to extend the existing XSD, or make it less picky, please let me know :)

@Misiu
Copy link

Misiu commented Sep 20, 2016

@304NotModified I was only able to extend XSD by adding new target to it, below is EntityFramework target, so now I'm not getting any errors.

  <xs:complexType name="EntityFramework">
    <xs:complexContent>
      <xs:extension base="Target">
        <xs:choice minOccurs="0" maxOccurs="unbounded">
          <xs:element name="name" minOccurs="0" maxOccurs="1" type="xs:string" />
          <xs:element name="connectionStringName" minOccurs="0" maxOccurs="1" type="xs:string" />
          <xs:element name="keepConnection" minOccurs="0" maxOccurs="1" type="xs:boolean" />
          <xs:element name="commandText" minOccurs="0" maxOccurs="1" type="Layout" />
          <xs:element name="parameter" minOccurs="0" maxOccurs="unbounded" type="NLog.Targets.DatabaseParameterInfo" />
        </xs:choice>
        <xs:attribute name="name" type="xs:string">
          <xs:annotation>
            <xs:documentation>Name of the target.</xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="connectionStringName" type="xs:string">
          <xs:annotation>
            <xs:documentation>Name of the connection string (as specified in &lt;connectionStrings&gt; configuration section.</xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="keepConnection" type="xs:boolean">
          <xs:annotation>
            <xs:documentation>Indicates whether to keep the database connection open between the log events.</xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="commandText" type="SimpleLayoutAttribute">
          <xs:annotation>
            <xs:documentation>Text of the SQL command to be run on each log level.</xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants