# How to show the logs of Appium server programmatically?

**URL:** <https://discuss.appium.io/t/how-to-show-the-logs-of-appium-server-programmatically/29547>\
**Category:** Support\
**Created:** [February 4, 2020, 12:55pm UTC](https://discuss.appium.io/t/how-to-show-the-logs-of-appium-server-programmatically/29547 "2020-02-04T12:55:54Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![fgh](https://discuss.appium.io/letter_avatar_proxy/v4/letter/f/71c47a/32.png) [@fgh](https://discuss.appium.io/u/fgh)\
**Post date:** [February 4, 2020, 12:55pm UTC](https://discuss.appium.io/t/how-to-show-the-logs-of-appium-server-programmatically/29547/1 "2020-02-04T12:55:54Z")

</div>

Hi guys,

I am using Python 3.7.

I finally managed to launch Appium programmatically. But I can’t see the log anymore.  
I was used to see the log from Appium view. Now I get lost. I need your help please.  
I found this doc:  
[http://appium.io/docs/en/commands/session/logs/get-log/#get-logs](http://appium.io/docs/en/commands/session/logs/get-log/#get-logs)

Which says to add this line:  
logs = driver.get\_log(‘driver’);

It looks weird for me to add a “;” at the end of a python line (but I am newbie, so I did as it said).

But it didn’ show anything. So I added this line:  
print(f"Logs : {logs}")

And it didn’t show anything again.

Does any Python expert can tell me the lines of code to store or display the logs of Appium server.

Thanks.

Kind regards

---

<div class="post-metadata">

**Author:** ![Cory-Berg](https://discuss.appium.io/letter_avatar_proxy/v4/letter/c/65b543/32.png) [@Cory-Berg](https://discuss.appium.io/u/Cory-Berg)\
**Post date:** [February 4, 2020, 3:57pm UTC](https://discuss.appium.io/t/how-to-show-the-logs-of-appium-server-programmatically/29547/2 "2020-02-04T15:57:31Z")

</div>

First I would try:  
log\_types = driver.log\_types();  
Then I would try:  
logs = driver.get\_log(‘server’);  
You should be able to request any of the log types returned from the first call.

Cory

---

<div class="post-metadata">

**Author:** ![fgh](https://discuss.appium.io/letter_avatar_proxy/v4/letter/f/71c47a/32.png) [@fgh](https://discuss.appium.io/u/fgh)\
**Post date:** [February 4, 2020, 5:36pm UTC](https://discuss.appium.io/t/how-to-show-the-logs-of-appium-server-programmatically/29547/3 "2020-02-04T17:36:15Z")

</div>

Sorry, what do you mean by ‘server’

I have only these lines to start server:  
appium\_service = AppiumService()  
appium\_service.start()

Do you mean the ip:port  
Example:  
logs = driver.get\_log(‘127.0.0.1:4723’)  
?

Thanks for your help

---

<div class="post-metadata">

**Author:** ![Cory-Berg](https://discuss.appium.io/letter_avatar_proxy/v4/letter/c/65b543/32.png) [@Cory-Berg](https://discuss.appium.io/u/Cory-Berg)\
**Post date:** [February 5, 2020, 4:00pm UTC](https://discuss.appium.io/t/how-to-show-the-logs-of-appium-server-programmatically/29547/4 "2020-02-05T16:00:35Z")

</div>

When requesting the logs you specify which ‘type’ of logs you want.  
You can get a list of what type of logs are available with the log\_types(); but it is likely you are interested in requesting the ‘server’ type logs if that makes sense? Thus the call driver.get\_log(‘server’); would return the logs your appium server you launched programmatically and created a session with.

---

<div class="post-metadata">

**Author:** ![Conrad\_Braam](https://discuss.appium.io/user_avatar/discuss.appium.io/conrad_braam/32/7031_2.png) [@Conrad\_Braam](https://discuss.appium.io/u/Conrad_Braam)\
**Post date:** [February 6, 2020, 10:51am UTC](https://discuss.appium.io/t/how-to-show-the-logs-of-appium-server-programmatically/29547/5 "2020-02-06T10:51:50Z")

</div>

The logs are only available if you have the security settings to allow this. It seems you have to start the server with a few flags --relaxed-security , or be more specific about it by reading this link. [https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/security.md](https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/security.md)

---

<div class="post-metadata">

**Author:** ![fgh](https://discuss.appium.io/letter_avatar_proxy/v4/letter/f/71c47a/32.png) [@fgh](https://discuss.appium.io/u/fgh)\
**Post date:** [February 6, 2020, 5:02pm UTC](https://discuss.appium.io/t/how-to-show-the-logs-of-appium-server-programmatically/29547/6 "2020-02-06T17:02:35Z")

</div>

Thank you for your help.  
I educated myself more about python logs And I made some experiments with 3 ways to sart Appium server before to come back to you.

I tried by this way:  
appium\_service = AppiumService()  
appium\_service.start()

But I don’t see any log. I guess I need to modify the python file of appium\_service method.

So I tried to start appium server with command (I added the flag of scurity you suggested):  
`os.system("start /B start cmd.exe @cmd /k appium --relaxed-security --log-timestamp --log appium.log -a 127.0.0.1 -p 4728")`  
I could see some logs in terminal but not so much than Appium GUI server.

 ![appium_log](https://discuss.appium.io/uploads/default/original/2X/d/d91c491139e4ce546c8ca1e951c66bb2a7d2f71e.jpeg)

To show you the difference, I commented the lines of code which start Appium server, and I start it by hand with Appium GUI.

 ![appium_logs_gui](https://discuss.appium.io/uploads/default/original/2X/f/f1d9d9709a1422fb8280315be487180863b4a1d6.jpeg)

As you can see Appium GUI logs give more information to debug my code.

What should I do to display same info in Appium terminal than Appium GUI?  
What should I do to display same info in ‘appium\_service.start()’ than Appium GUI?

Thanks a lot again for your help.

---

<div class="post-metadata">

**Author:** ![Cory-Berg](https://discuss.appium.io/letter_avatar_proxy/v4/letter/c/65b543/32.png) [@Cory-Berg](https://discuss.appium.io/u/Cory-Berg)\
**Post date:** [February 10, 2020, 8:13pm UTC](https://discuss.appium.io/t/how-to-show-the-logs-of-appium-server-programmatically/29547/7 "2020-02-10T20:13:12Z")

</div>

–log-level debug:debug --debug-log-spacing

---

<div class="post-metadata">

**Author:** ![fgh](https://discuss.appium.io/letter_avatar_proxy/v4/letter/f/71c47a/32.png) [@fgh](https://discuss.appium.io/u/fgh)\
**Post date:** [February 11, 2020, 6:52am UTC](https://discuss.appium.io/t/how-to-show-the-logs-of-appium-server-programmatically/29547/8 "2020-02-11T06:52:13Z")

</div>

Thank you. I should add these flags in the windows command or sOmewhere in the code of appium\_service?

---

<div class="post-metadata">

**Author:** ![Conrad\_Braam](https://discuss.appium.io/user_avatar/discuss.appium.io/conrad_braam/32/7031_2.png) [@Conrad\_Braam](https://discuss.appium.io/u/Conrad_Braam)\
**Post date:** [March 16, 2020, 11:46am UTC](https://discuss.appium.io/t/how-to-show-the-logs-of-appium-server-programmatically/29547/9 "2020-03-16T11:46:18Z")

</div>

Gautier  
It looks like you run appium inside your test tool, so just adding those 2 flags should do what you want. What worries me, is that you probably tried that already and did not get joy the first time.

---

<div class="post-metadata">

**Author:** ![Alejandro\_Delgado](https://discuss.appium.io/user_avatar/discuss.appium.io/alejandro_delgado/32/10907_2.png) [@Alejandro\_Delgado](https://discuss.appium.io/u/Alejandro_Delgado)\
**Post date:** [December 30, 2022, 9:08pm UTC](https://discuss.appium.io/t/how-to-show-the-logs-of-appium-server-programmatically/29547/10 "2022-12-30T21:08:19Z")

</div>

hello fgh  
try adding arguments to your code

option 1  
import os  
os.system(“start /B start cmd.exe @cmd /k appium -a 0.0.0.0 -p 4723 -pa /wd/hub”)  
still don’t know how to stop appium

option 2  
from appium.webdriver.appium\_service import AppiumService  
appium\_service = AppiumService()  
appium\_service.start(args=[’–automation-name’, ‘Appium’, ‘-a’, ‘localhost’, ‘-p’, ‘4723’, ‘-pa’, ‘/wd/hub’, ‘-bp’, ‘4723’])  
appium\_service.stop()
