简体   繁体   English

如何在 Java 中读取 SQL 服务器日志 (XEL) 文件

[英]How to read SQL server logs (XEL) files in Java

I am trying to process the SQL server log file (XEL) in Java and convert into other format like JSON.我正在尝试用 Java 处理 SQL 服务器日志文件 (XEL) 并转换为其他格式,如 JSON。 I am not able to find any documentation on How to read XEL files and there are no library that can be used to read the XEL file.我找不到有关如何读取 XEL 文件的任何文档,并且没有可用于读取 XEL 文件的库。

Any pointers will be helpful.任何指针都会有所帮助。 Thanks in advance提前致谢

Indeed, I tried to search for a library to parse XEL format file in Java, but failed.确实,我试图搜索一个库来解析Java中的XEL格式文件,但失败了。 I think a workaround solution to satisfy your needs may should be considered by you.我认为您可能应该考虑一种满足您需求的变通解决方案。

Here is some workaround solutions in my mind.这是我脑海中的一些变通解决方案。

  1. There are some tools to help parsing XEL format file, such as Log Parser 2.2 and Read-DbaXEFile function of PowerShell Module sqlcollaborative/dbatools .有一些工具可以帮助解析 XEL 格式的文件,例如Log Parser 2.2和 PowerShell Module sqlcollaborative/dbatools Read-DbaXEFile函数。 For Log Parser 2.2 usage, please refer to the blogs How to parse SQL Server Error Log with Log Parser 2.2 and Microsoft's Log Parser Utility: Swell ETL .有关Log Parser 2.2用法,请参阅博客How to parse SQL Server Error Log with Log Parser 2.2Microsoft 的 Log Parser Utility:Swell ETL For function Read-DbaXEFile , please see its source code https://github.com/sqlcollaborative/dbatools/blob/master/functions/Read-DbaXEFile.ps1 .对于函数Read-DbaXEFile ,请参阅其源代码https://github.com/sqlcollaborative/dbatools/blob/master/functions/Read-DbaXEFile.ps1

  2. There is a nuget package named XELite in C#, which be cross platform library to read XEvents from XEL files or live SQL streams.在 C# 中有一个名为XELite的 nuget 包,它是一个跨平台库,用于从 XEL 文件或实时 SQL 流中读取 XEvent。

Considering for your scenario, I think you can try to the two workaround solution to parse XEL format files stored in Azure Storage first within Azure Functions in C# or PowerShell with Blob Trigger , or within Azure Data Factory with a Custom activity , to extract these data what you want for further data processing in Spark.考虑到您的情况,我认为您可以尝试使用两种解决方法来解析存储在 Azure 存储中的 XEL 格式文件,首先在C#PowerShell 中使用Blob Trigger 的Azure Functions 中,或在具有自定义活动的Azure 数据工厂中,以提取这些数据你想要在 Spark 中进一步处理数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM