# Web extension : add logs

**URL:** https://discourse.mozilla.org/t/web-extension-add-logs/73423
**Category:** Development
**Created:** [January 7, 2021, 9:27pm UTC](https://discourse.mozilla.org/t/web-extension-add-logs/73423 "2021-01-07T21:27:07Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![usero16](https://avatars.discourse-cdn.com/v4/letter/u/cab0a1/32.png) [@usero16](https://discourse.mozilla.org/u/usero16)
#### Post date: [January 7, 2021, 9:27pm UTC](https://discourse.mozilla.org/t/web-extension-add-logs/73423/1 "2021-01-07T21:27:07Z")

</div>

I created a web extension (Firefox). I want to add logs to a external file (example: console.txt) from the content scripts and the background script. For example : write “Begin web extension”.

How can i do that? Thank you in advance for your help

---

<div class="post-metadata">

### Author: ![freaktechnik](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/freaktechnik/32/37766_2.png) [@freaktechnik](https://discourse.mozilla.org/u/freaktechnik)
#### Post date: [January 8, 2021, 9:07am UTC](https://discourse.mozilla.org/t/web-extension-add-logs/73423/2 "2021-01-08T09:07:05Z")

</div>

You can not write to an external file. Check out [https://extensionworkshop.com/documentation/develop/debugging/](https://extensionworkshop.com/documentation/develop/debugging/) for techniques of troubleshooting issues.

If you want to have a debug log for diagnostics, you would collect the logs in-memory and then offer a [“download”](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Working_with_files#download_files_using_the_downloads_api) to the user or a way to copy the log contents to the clipboard.

---

<div class="post-metadata">

### Author: ![Marcus\_Stricker](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/marcus_stricker/32/43477_2.png) [@Marcus\_Stricker](https://discourse.mozilla.org/u/Marcus_Stricker)
#### Post date: [January 9, 2021, 5:14pm UTC](https://discourse.mozilla.org/t/web-extension-add-logs/73423/4 "2021-01-09T17:14:33Z")

</div>

Hi freaktechnik,

can i write to a database ?  
maybe via sql connection to a mssql database ?

thanks

br caddy

---

<div class="post-metadata">

### Author: ![freaktechnik](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/freaktechnik/32/37766_2.png) [@freaktechnik](https://discourse.mozilla.org/u/freaktechnik)
#### Post date: [January 9, 2021, 5:16pm UTC](https://discourse.mozilla.org/t/web-extension-add-logs/73423/5 "2021-01-09T17:16:22Z")

</div>

There are multiple storage facilities available:  
[https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/storage](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/storage)

or the DOM `localStorage` or [`indexedDB`](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API) APIs.

---

<div class="post-metadata">

### Author: ![jscher2000](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/jscher2000/32/28202_2.png) [@jscher2000](https://discourse.mozilla.org/u/jscher2000)
#### Post date: [January 10, 2021, 8:39pm UTC](https://discourse.mozilla.org/t/web-extension-add-logs/73423/6 "2021-01-10T20:39:31Z")

</div>

> [@Marcus\_Stricker](#):
>
> can i write to a database ?  
> maybe via sql connection to a mssql database ?

Extensions don’t have any SQL Server libraries, so they need an intermediary such as a web application or local native application to write to SQL Server. These are both inconvenient for users to set up, so using the built-in storage facilities would be more convenient if you intend that for deployment. Well, even just for yourself…

---

<div class="post-metadata">

### Author: ![Marcus\_Stricker](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/marcus_stricker/32/43477_2.png) [@Marcus\_Stricker](https://discourse.mozilla.org/u/Marcus_Stricker)
#### Post date: [January 11, 2021, 8:03am UTC](https://discourse.mozilla.org/t/web-extension-add-logs/73423/7 "2021-01-11T08:03:07Z")

</div>

Thanks for the answers

br caddy
