如何使用Notepad++快速整理挤在一起的CallStack信息(将换行符作为被替换的内容)
问题描述
=====================
经常需要在SharePoint的ULS日志中捞取一些带有callstack的信息, 而且需要把callstack展开细细查看. 然而, ULS log中的callstack是挤在一起的, 查看起来很不方便.
笔者原来一直手工添加换行符, 但是近期这类工作实在有点多, 于是开始想办法了.
问题举例, 笔者从ULS log中捞到这个CallStack,
Error while executing web part: Microsoft.BusinessData.Infrastructure.BdcException: The shim execution failed unexpectedly - Target application not found (application id: AdventureApp).. ---> Microsoft.Office.SecureStoreService.Server.SecureStoreServiceTargetApplicationNotFoundException: Target application not found (application id: AdventureApp). at Microsoft.Office.SecureStoreService.Server.SecureStoreServiceApplicationProxy.Execute[T](String operationName, Boolean validateCanary, ExecuteDelegate`1 operation) at Microsoft.Office.SecureStoreService.Server.SecureStoreServiceApplicationProxy.GetRestrictedCredentials(Guid rawPartitionId, String applicationId) at Microsoft.Office.SecureStoreService.Server.SecureStoreProvider.GetRestrictedCredentials(String appId) at Microsoft....
...SharePoint.BusinessData.SystemSpecific.Db.DbConnectionManager.GetConnection() at Microsoft.SharePoint.BusinessData.SystemSpecific.Db.DbSystemUtility.ExecuteStatic(IMethodInstance methodInstance, ILobSystemInstance lobSystemInstance, Object[] args, IExecutionContext context) at Microsoft.SharePoint.BusinessData.Runtime.DataClassRuntime.ExecuteInternalWithAuthNFailureRetry(ISystemUtility systemUtility, IMethodInstance methodInstanceToExecute, IMethod methodToExecute, ILobSystemInstance lobSystemInstance, ILobSystem lobSystem, IParameterCollection nonReturnParameters, Object[] overrideArgs) at Microsoft.SharePoint.BusinessData.Runtime.DataClassRuntime.ExecuteInternal(IDataClass thisDataClass, ILobSystemInstance lobSystemInstance, ILobSystem lobSystem, IMethodInstance methodInstanc...
...eToExecute, IMethod methodToExecute, IParameterCollection nonReturnParameters, Object[]& overrideArgs) --- End of inner exception stack trace --- at Microsoft.SharePoint.BusinessData.Runtime.DataClassRuntime.ExecuteInternal(IDataClass thisDataClass, ILobSystemInstance lobSystemInstance, ILobSystem lobSystem, IMethodInstance methodInstanceToExecute, IMethod methodToExecute, IParameterCollection nonReturnParameters, Object[]& overrideArgs) at Microsoft.SharePoint.BusinessData.Runtime.EntityRuntime.ExecuteInternal(IDataClass thisDataClass, ILobSystemInstance lobSystemInstance, ILobSystem lobSystem, IMethodInstance methodInstanceToExecute, IMethod methodToExecute, IParameterCollection nonReturnParameters, Object[]& overrideArgs, IFilterCollection filters) at Microsoft.SharePoin...
...t.BusinessData.Runtime.EntityRuntime.ExecuteFiltered(IEntity this, IFilterCollection filterCollection, IMethodInstance methodInstanceToExecute, ILobSystemInstance lobSystemInstance) at Microsoft.SharePoint.BusinessData.Runtime.EntityRuntime.<FindFiltered>b__3(IEntity e, IMethodInstance mi, IFilterCollection fc, ILobSystemInstance lsi) at Microsoft.SharePoint.BusinessData.Runtime.EntityInstanceEnumeratorFactory.CreateEntityInstanceEnumerator(IEntity entity, IMethodInstance methodInstance, IFilterCollection filters, ILobSystemInstance lobSystemInstance, ExecutionCallBack executionCallBack) at Microsoft.SharePoint.BusinessData.MetadataModel.Static.Entity.FindFiltered(IFilterCollection filterCollection, String finderName, ILobSystemInstance lobSystemInstance) at Microsoft.Share...
...Point.SPListDataSource.GetEntityInstanceEnumerator(XmlNode xnMethodAndFilters) at Microsoft.SharePoint.SPListDataSource.GetFilteredEntityInstancesInternal(XmlDocument xdQueryView, Boolean fFormatDates, Boolean fUTCToLocal, String firstRowId, Boolean fBackwardsPaging, String& bdcidFirstRow, String& bdcidNextPageRow, List`1& lstColumnNames, Dictionary`2& dictColumnsUsed, List`1& mapRowOrdering, List`1& lstEntityData) at Microsoft.SharePoint.SPListDataSource.GetFilteredEntityInstances(XmlDocument xdQueryView, Boolean fFormatDates, Boolean fUTCToLocal, String firstRowId, Boolean fBackwardsPaging, String& bdcidFirstRow, String& bdcidNextPageRow, List`1& lstColumnNames, Dictionary`2& dictColumnsUsed, List`1& mapRowOrdering, List`1& lstEntityData) at Microsoft.SharePoint.SPListItemCol...
...lection.EnsureEntityDataViewAndOrdering(String& bdcidFirstRow, String& bdcidNextPageFirstRow) at Microsoft.SharePoint.SPListItemCollection.EnsureListItemsData() at Microsoft.SharePoint.SPListItemCollection.get_Count() at Microsoft.SharePoint.WebControls.SPDataSourceView.ExecuteSelect(DataSourceSelectArguments selectArguments, String aggregateString, Boolean wantReturn, BaseXsltListWebPart webpart, SPListItem& listItem, SPListItemCollection& listItems, String[]& fieldList) at Microsoft.SharePoint.WebControls.SingleDataSource.GetXPathNavigatorInternal() at Microsoft.SharePoint.WebControls.SingleDataSource.GetXPathNavigator() at Microsoft.SharePoint.WebPartPages.DataFormWebPart.PrepareAndPerformTransform(Boolean bDeferExecuteTransform)
研究
=====================
在Notepad++中新建一个文件, 随便输入几行文字
点击下面的选项
结果如下, 显然CR, LF是换行符.
使用CR, LF, Notepad++作为关键字, 经过搜索, 在Notepad++的官网上找到了如下的文字:
Ctrl+H with Extended option selected instead of Regexp. Search for "\r\n", or whatever your OS uses, and replace with what you need. It will replace the newline characters with what you entered. Note that Windows uses CR-LF newlines (\r\n), old Mac uses CR (\r) and Unix uses LF (\n). You can use View -> Show Symbol -> Show End Of Line to see which characters your file uses - files from other OSes may not behave as you expect because they have a different newline type.
Some examples: - To add a string to the end of all lines in Windows, in Ctrl+H with Extended mode enabled, replace \r\n with string\r\n - To add a string to the beginning of all lines in windows, in Ctrl+H with Extended mode enabled, replace \r\n with \r\nstring - To remove extra blank lines in windows, in Ctrl+H with Extended mode enabled, replace \r\n\r\n with \r\n - To remove all newlines, in Ctrl+H with Extended mode enabled, replace \r\n with nothing.
解决方案
=====================
使用Notepad++, 将内容贴入:
呼出替换对话框, 将<at>替换为<\r\nat>, 不包括尖括号.
结果如下:
就用这个技巧作为开端吧, 善用notepad++, 让工作效率疾驰如飞.
参考资料
=====================
How To Replace Line Ends, thus changing the line layout
http://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=Replacing_Newlines
Replace a "comma space" with a new line in notepad++
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律