[SQL]Log all database errors.

02/26/2015 17:40 Royalblade*#1
A friend of mine was just asking me that he'd got a sql error displayed in the gameserver.

Sometimes, it gets difficult tracing errors since you don't know where exactly they happen. The gameserver does not necessarily give you all kind of information.

The error log can be viewed using the [Only registered and activated users can see links. Click Here To Register...]. Not gonna show you how to read something so simple. People that don't speak english will fail right here (camels literally).

Isn't it awesome how you can release things for people who aren't handicapped by birth?

Code:
CREATE EVENT SESSION [ErrorCapture] 
ON SERVER 
ADD EVENT sqlserver.error_reported
(
    ACTION
    (
        sqlserver.client_hostname,
        sqlserver.database_id,
        sqlserver.sql_text,
        sqlserver.username
    )
    WHERE 
    (
        [severity] >= (11)
    )
) 
ADD TARGET package0.asynchronous_file_target
(
    SET filename=N'C:\ErrorLog\ErrorCapture.xel'
)
WITH 
(
    MAX_MEMORY=4096 KB,
    EVENT_RETENTION_MODE=ALLOW_SINGLE_EVENT_LOSS,
    MAX_DISPATCH_LATENCY=30 SECONDS,
    MAX_EVENT_SIZE=0 KB,
    MEMORY_PARTITION_MODE=NONE,
    TRACK_CAUSALITY=OFF,
    STARTUP_STATE=ON
);
GO

ALTER EVENT SESSION [ErrorCapture]
ON SERVER
STATE = START;
GO
PS: This isn't written by me.