Extended Events - Object cannot be added to the event session
Asked Answered
A

2

7

When I am trying to run Extended Event:

CREATE EVENT SESSION [Loading] ON SERVER  
ADD EVENT sqlserver.sql_statement_completed(SET collect_statement=(1)) 
ADD TARGET package0.event_file(SET filename=N'C:\Users\user\Documents\test.xel',max_file_size=(10)) 
WITH (MAX_MEMORY=4096 KB,EVENT_RETENTION_MODE=ALLOW_SINGLE_EVENT_LOSS,MAX_DISPATCH_LATENCY=3 SECONDS,MAX_EVENT_SIZE=0 KB,MEMORY_PARTITION_MODE=NONE,TRACK_CAUSALITY=OFF,STARTUP_STATE=OFF) 
GO 

on SQL Server 2016, I get:

The target, "5B2DA06D-898A-43C8-9309-39BBBE93EBBD.package0.event_file", encountered a configuration error during initialization. Object cannot be added to the event session. The operating system returned error 5: 'Access is denied. ' while creating the file 'C:\Users\user\Documents\test_0_131207679384970000.xel'. (Microsoft SQL Server, Error: 25602)

Where is the problem? I have enough permission for C:\Users\user\Documents.

Alcantara answered 12/10, 2016 at 17:34 Comment(2)
Who is "I"? In order to create the file, the account that the SQL Server service is running under must have permission. By default, this is a custom-generated local account that only has permissions to access database files.Clubfoot
@JeroenMostert My user windows user.Alcantara
S
3

You need to grant write permission to that folder to NTService\MSSQLServer, which is what the SQL Server service runs as.

Strangeness answered 20/6, 2017 at 22:1 Comment(0)
F
0

You can use "C:\Temp" folder and it should work.

Fabricant answered 9/6, 2020 at 9:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.