log4net에서 PostgreSql로 내보내기
8867 단어 C#databasePostgreSQLlog4net
프로파일을 직접 업로드합니다.
<!-- PostgreSql , Windows Service -->
<appender name="AdoNetAppender_PostgreSQL_All" type="log4net.Appender.AdoNetAppender">
<bufferSize value="10"/>
<connectionType value="Npgsql.NpgsqlConnection, Npgsql"/>
<!--PostgreSql -->
<connectionString value="Server=127.0.0.1;Port=5432;User Id=postgres;Password=tm;Database=postgres;"/>
<!--PostgreSql -->
<!-- PostgreSql , "
Ormlite,
<commandText value="INSERT INTO "Log"
("AppDomain", "AspnetCache", "AspnetContext", "AspnetRequest", "AspnetSession",
"Logger", "Date", "Identity", "Level", "Location", "Exception",
"Message", "Thread", "NDC", "StackTraceDetail", "UserName", "UTCDate")
VALUES
(:AppDomain, :AspnetCache, :AspnetContext, :AspnetRequest, :AspnetSession, :Logger, :Date, :Identity, :Level, :Location, :Exception,
:Message, :Thread, :NDC, :StackTraceDetail, :UserName, :UTCDate)"/>
-->
<!-- Ormlite , -->
<commandText value="INSERT INTO log
(app_domain, aspnet_cache, aspnet_context, aspnet_request, aspnet_session,
logger, date_time, identity, level, location, exception,
message, thread, ndc, stack_trace_detail, user_name, utc_date)
VALUES
(:AppDomain, :AspnetCache, :AspnetContext, :AspnetRequest, :AspnetSession, :Logger, :Date, :Identity, :Level, :Location, :Exception,
:Message, :Thread, :NDC, :StackTraceDetail, :UserName, :UTCDate)"/>
<parameter>
<parameterName value="AppDomain"/>
<dbType value="String"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%appdomain"/>
</layout>
</parameter>
<parameter>
<parameterName value="AspnetCache"/>
<dbType value="String"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%aspnet-cache"/>
</layout>
</parameter>
<parameter>
<parameterName value="AspnetContext"/>
<dbType value="String"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%aspnet-context"/>
</layout>
</parameter>
<parameter>
<parameterName value="AspnetRequest"/>
<dbType value="String"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%aspnet-request"/>
</layout>
</parameter>
<parameter>
<parameterName value="AspnetSession"/>
<dbType value="String"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%aspnet-session"/>
</layout>
</parameter>
<parameter>
<parameterName value="Logger"/>
<dbType value="String"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%logger"/>
</layout>
</parameter>
<parameter>
<parameterName value="Date"/>
<dbType value="DateTime"/>
<layout type="log4net.Layout.RawTimeStampLayout"/>
</parameter>
<parameter>
<parameterName value="Identity"/>
<dbType value="String"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%identity"/>
</layout>
</parameter>
<parameter>
<parameterName value="Level"/>
<dbType value="String"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%level"/>
</layout>
</parameter>
<parameter>
<parameterName value="Location"/>
<dbType value="String"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%location"/>
</layout>
</parameter>
<parameter>
<parameterName value="Exception"/>
<dbType value="String"/>
<layout type="log4net.Layout.ExceptionLayout">
</layout>
</parameter>
<parameter>
<parameterName value="Message"/>
<dbType value="String"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%message"/>
</layout>
</parameter>
<parameter>
<parameterName value="Thread"/>
<dbType value="String"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%thread"/>
</layout>
</parameter>
<parameter>
<parameterName value="NDC"/>
<dbType value="String"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%ndc"/>
</layout>
</parameter>
<parameter>
<parameterName value="StackTraceDetail"/>
<dbType value="String"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%stacktracedetail{10}"/>
</layout>
</parameter>
<parameter>
<parameterName value="UserName"/>
<dbType value="String"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%username"/>
</layout>
</parameter>
<parameter>
<parameterName value="UTCDate"/>
<dbType value="DateTime"/>
<layout type="log4net.Layout.RawUtcTimeStampLayout"/>
</parameter>
</appender>
실행할 때 현재 디렉터리에 Npgsql이 있어야 합니다.dll, 그리고 PgSQL에 표를 작성하여 좋은 사람이 끝까지 하고 Ormlite가 생성한 SQL을 바칩니다.
-- Table: log
-- DROP TABLE log;
CREATE TABLE log
(
id serial NOT NULL,
date_time timestamp without time zone NOT NULL,
thread text,
level text,
logger text,
message text,
exception text,
stack_trace_detail text,
location text,
identity text,
app_domain text,
user_name text,
ndc text,
utc_date timestamp without time zone,
aspnet_cache text,
aspnet_context text,
aspnet_request text,
aspnet_session text,
CONSTRAINT log_pkey PRIMARY KEY (id)
)
WITH (
OIDS=FALSE
);
ALTER TABLE log
OWNER TO postgres;
-- Index: idx_log_level
-- DROP INDEX idx_log_level;
CREATE INDEX idx_log_level
ON log
USING btree
(level COLLATE pg_catalog."default");
-- Index: uidx_log_date
-- DROP INDEX uidx_log_date;
CREATE UNIQUE INDEX uidx_log_date
ON log
USING btree
(date);
스티커를 보내고 나서야 시스템이 "를 큰따옴표로 해석한 다음
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
WebView2를 Visual Studio 2017 Express에서 사용할 수 있을 때까지Evergreen .Net Framework SDK 4.8 VisualStudio2017에서 NuGet을 사용하기 때문에 패키지 관리 방법을 packages.config 대신 PackageReference를 사용해야...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.