如何使用文件而不是db?

时间:2017-05-19 10:57:33

标签: c# .net azure search logging

我的应用程序有很多日志。目前我写入azure blob文件的部分日志,其中一部分写入db。 我只需要在blob或机器上使用文件。我需要有可能查询和过滤此文件的行以找到我需要的。我不需要使用现有日志,我可以创建任何预定义的结构。 鉴于db大小的快速增长,我不想使用db的原因是db的成本。 那么,实现这个的最佳方法是什么? 我会很高兴有任何建议。

1 个答案:

答案 0 :(得分:0)

根据您正在记录的 ,应用程序日志通常使用var linkTreeObject = { "langs": [{ "lang": "de", "lines": { "menu": [{ "title": "Anleitung", "link": "/de/anleitung" }, { "title": "Funktionen", "link": "/de/funktionen" }, { "title": "Dienstleistungen", "link": "/de/dienstleistungen", "children": [{ "title": "Geistiges Eigentum", "link": "/de/dienstleistungen/geistiges-eigentum" }, { "title": "Compliance", "link": "/de/dienstleistungen/compliance" }, { "title": "Investment- und Beteiligungsrecht", "link": "/de/dienstleistungen/beteiligungsrecht" }, { "title": "Mergers & Acquisitions", "link": "/de/dienstleistungen/mergers-and-acquisitions" }, { "title": "Immobilienrecht", "link": "/de/dienstleistungen/immobilienrecht" }, { "title": "Internet- und Datenschutzrecht", "link": "/de/dienstleistungen/internetrecht" }, { "title": "Gesellschaftsrecht", "link": "/de/dienstleistungen/gesellschaftsrecht" }, { "title": "Handelsrecht", "link": "/de/dienstleistungen/handelsrecht" }, { "title": "Arbeitsrecht", "link": "/de/dienstleistungen/arbeitsrecht" }, { "title": "Bankrecht", "link": "/de/dienstleistungen/bankrecht" }, { "title": "Vertragsrecht", "link": "/de/dienstleistungen/vertragsrecht" }, { "title": "Wettbewerbsrecht", "link": "/de/dienstleistungen/wettbewerbsrecht" }] }, { "title": "Beliebte Projekte", "link": "/de/beliebte-projekte", "children": [{ "title": "Compliance", "link": "/de/beliebte-projekte/compliance", "children": [{ "title": "Haftungsrisiken für Geschäftsführern", "link": "/de/beliebte-projekte/compliance/haftungsrisken-geschaeftsfuehrern" }, { "title": "Compliance-Prüfung KMU", "link": "/de/beliebte-projekte/compliance/compliance-pruefung-kmu" }] }] }], "sign_in": "Login" } }, { "lang": "en", "lines": { "menu": [{ "title": "How it works", "link": "/en/how-it-works" }, { "title": "Features", "link": "/en/features" }, { "title": "Services", "link": "/en/services", "children": [{ "title": "Intellectual property", "link": "/en/services/intellectual-property" }, { "title": "Compliance", "link": "/en/services/compliance" }, { "title": "Investment law", "link": "/en/services/investment-law" }, { "title": "Mergers & Acquisitions", "link": "/en/services/mergers-and-acquisitions" }, { "title": "Real estate law", "link": "/en/services/real-estate-law" }, { "title": "Internet law and data privacy", "link": "/en/services/internet-law" }, { "title": "Company law", "link": "/en/services/company-law" }, { "title": "Trade law", "link": "/en/services/trade-law" }, { "title": "Labour law", "link": "/en/services/labour-law" }, { "title": "Bank law", "link": "/en/services/bank-law" }, { "title": "Contract law", "link": "/en/services/contract-law" }, { "title": "Competition law", "link": "/en/services/competition-law" }] }, { "title": "Popular Projects", "link": "/en/popular-projects", "children": [{ "title": "Compliance", "link": "/en/popular-projects/compliance", "children": [{ "title": "Haf eng", "link": "/en/popular-projects/compliance/haf-eng" }, { "title": "Compliance eng", "link": "/en/popular-projects/compliance/compliance-eng" }] }] }], "sign_in": "Sign in" } }] }; function getUrl(pairUrl, currentLng, enMenu, deMenu, obj) { for (let k in obj) { if (!obj.hasOwnProperty(k)) continue if (obj[k].link === pairUrl) { if (currentLng === 'de') { return enMenu[k].link // get en link equivlant } else { return deMenu[k].link // get de link equivlant } } else { if (!obj[k].hasOwnProperty('children') || obj[k].children.length <= 0) continue; var ret = getUrl(pairUrl, currentLng, enMenu[k].children, deMenu[k].children, obj[k].children); if(typeof ret != 'undefined') return ret; } } } function getLanguagePair(currentLng, pairUrl) { // 'find url in json tree' var enMenu = linkTreeObject.langs[1].lines.menu var deMenu = linkTreeObject.langs[0].lines.menu let obj = {} // find position in tree if (currentLng === 'de') { obj = deMenu } else { obj = enMenu } return getUrl(pairUrl, currentLng, enMenu, deMenu, obj) } //works console.log(getLanguagePair("en", "/en/how-it-works")) console.log(getLanguagePair("en", "/en/popular-projects")) console.log(getLanguagePair("de", "/de/anleitung")) console.log(getLanguagePair("de", "/de/beliebte-projekte")) //fail console.log(getLanguagePair("en", "/en/services/compliance")) console.log(getLanguagePair("en", "/en/popular-projects/compliance")) console.log(getLanguagePair("en", "/en/popular-projects/compliance/compliance-eng"))类编写。可以通过门户配置日志级别和存储(文件或blob)。详细了解here